কম্পিউটার টিউটোরিয়াল

TensorFlow ব্যবহার করে Fashion MNIST ডেটাসেট ডাউনলোড ও এক্সপ্লোর করা

TensorFlow হল Google প্রদত্ত একটি মেশিন লার্নিং ফ্রেমওয়ার্ক। এটি একটি ওপেন-সোর্স ফ্রেমওয়ার্ক যা পাইথনের সাথে সংযোগে অ্যালগরিদম, ডিপ লার্নিং অ্যাপ্লিকেশন ইত্যাদি বাস্তবায়নে ব্যবহৃত হয়। এটি গবেষণা এবং প্রোডাকশন উদ্দেশ্যে ব্যবহৃত হয়।

'tensorflow' প্যাকেজটি উইন্ডোজে নিচের কোড দিয়ে ইনস্টল করা যায়:

pip install tensorflow

'Fashion MNIST' ডেটাসেটে বিভিন্ন ধরনের পোশাকের ছবি রয়েছে। এতে ১০টি ভিন্ন ক্যাটাগরির ৭০ হাজারেরও বেশি পোশাকের গ্রেস্কেল ছবি রয়েছে। এই ছবিগুলোর রেজোলিউশন কম (২৮ x ২৮ পিক্সেল)।

নিচের কোড চালাতে আমরা Google Colaboratory ব্যবহার করছি। Google Colab বা Colaboratory ব্রাউজারের মাধ্যমে পাইথন কোড চালাতে সাহায্য করে এবং এটি শূন্য কনফিগারেশনের সাথে ফ্রি GPU অ্যাক্সেস প্রদান করে (Graphical Processing Units)। Colaboratory Jupyter Notebook-এর উপরে তৈরি।

কোড নিচে দেওয়া হল:

উদাহরণ

import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
print("The tensorflow version used is ")
print(tf.__version__)
print("The dataset is being loaded")
fashion_mnist = tf.keras.datasets.fashion_mnist
print("The dataset is being classified into training and testing data")
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data()
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']
print("The dimensions of training data ")
print(train_images.shape)
print("The number of rows in the training data")
print(len(train_labels))
print("The column names of dataset")
print(train_labels)
print("The dimensions of test data ")
print(test_images.shape)
print("The number of rows in the test data")
print(len(test_labels))

কোড ক্রেডিট - https://www.tensorflow.org/tutorials/keras/classification

আউটপুট

The tensorflow version used is 2.4.0
The dataset is being loaded
The dataset is being classified into training and testing data
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz 32768/29515 [=================================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-images-idx3-ubyte.gz 26427392/26421880 [==============================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-labels-idx1-ubyte.gz 8192/5148 [===============================================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-images-idx3-ubyte.gz 4423680/4422102 [==============================] - 0s 0us/step
The dimensions of training data (60000, 28, 28)
The number of rows in the training data 60000
The column names of dataset [9 0 0 ... 3 0 5]
The dimensions of test data (10000, 28, 28)
The number of rows in the test data 10000

ব্যাখ্যা

  • প্রয়োজনীয় প্যাকেজগুলো ইম্পোর্ট করা হয়েছে।

  • ব্যবহৃত TensorFlow-এর ভার্সন নির্ধারিত করা হয়েছে।

  • Fashion MNIST ডেটাসেট লোড করা হয়েছে, এবং এটি TensorFlow-এর মাধ্যমে সরাসরি অ্যাক্সেসযোগ্য।

  • পরবর্তীতে, ডেটা ট্রেনিং এবং টেস্টিং ডেটাসেটে বিভক্ত করা হয়েছে।

  • মোট ৭০০০০ সারি ডেটাসেটে রয়েছে, যার মধ্যে ৬০কে ইমেজ ট্রেনিং এবং ১০কে মডেল কত ভালো লার্ন করেছে ইমেজগুলো ভিন্ন লেবেলে ক্লাসিফাই করতে সেটা ইভ্যালুয়েট করার জন্য ব্যবহার করা হয়।

  • এটি একটি ক্লাসিফিকেশন সমস্যা যেখানে ডেটাসেটের প্রতিটি ইমেজকে একটি নির্দিষ্ট লেবেল দেওয়া হয়।

  • এই ইমেজগুলো পোশাকের, এবং তাদের সংশ্লিষ্ট লেবেল অ্যাসাইন করা হয়।

  • ট্রেনিং এবং টেস্ট ডেটাসেটের শেপ, সারি সংখ্যা এবং ডেটাসেটের কলাম নাম কনসোলে প্রদর্শিত হয়েছে।

  1. টেনসরফ্লো (TensorFlow) কীভাবে কেরাস সিকোয়েনশিয়াল API দিয়ে ফ্লাওয়ার ডেটাসেট এক্সপ্লোর (explore) করতে ব্যবহৃত হয়?

  2. টেনসরফ্লোতে ফ্লাওয়ার ডেটাসেট ভিজ্যুয়ালাইজ করা

  3. TensorFlow ব্যবহার করে Fashion MNIST ডেটাসেটে প্রশিক্ষিত মডেল দিয়ে ভিন্ন ইমেজ পূর্বাভাস করা

  4. TensorFlow ব্যবহার করে Fashion MNIST ডেটা প্রিপ্রসেস করা