This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import os, datetime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all files under the input directory | |
for dirname, _, filenames in os.walk('/kaggle/input'): | |
for filename in filenames: | |
print(os.path.join(dirname, filename)) | |
# List of physical devices | |
tf.config.experimental.list_physical_devices() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fashion_mnist = tf.keras.datasets.fashion_mnist | |
(train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() | |
# Creating class label array | |
class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Shape of training nad test data | |
print(f'Shape of train_images: {train_images.shape}') | |
print(f'Shape of train_labels: {train_labels.shape}') | |
print(f'Shape of test_images: {test_images.shape}') | |
print(f'Shape of test_labels: {test_labels.shape}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There are 10 labels starting from 0 to 9 | |
print(f'Unique train labels: {np.unique(train_labels)}') | |
print(f'Unique test labels: {np.unique(test_labels)}') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The images are 28x28 NumPy arrays, with pixel values ranging from 0 to 255 | |
train_images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.figure() | |
plt.imshow(train_images[0]) | |
plt.colorbar() | |
plt.grid(False) | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Images labels(classes) possible values from 0 to 9 | |
train_labels |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display the first 25 images from the training set and display the class name below each image. | |
plt.figure(figsize=(10,10)) | |
for i in range(25): | |
plt.subplot(5,5,i+1) | |
plt.xticks([]) | |
plt.yticks([]) | |
plt.grid(False) | |
plt.imshow(train_images[i], cmap=plt.cm.binary) | |
plt.xlabel(class_names[train_labels[i]]) | |
plt.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train_images = train_images / 255.0 | |
test_images = test_images / 255.0 |