# sequential model with two dense layers, # A Sequential model in TensorFlow is a linear stack of neural network # layers, where each layer is added one at a time. # Different types of layers, such as Dense layers (also called fully connected # layers), Convolutional layers, Pooling layers, and Recurrent layers can be # added. Also the activation function and other parameters for each layer can # be configured. import tensorflow as tf from tensorflow import keras import matplotlib.pyplot as plt import numpy as np # Load the MNIST Fashion dataset (x_train, y_train), (x_test, y_test) = keras.datasets.fashion_mnist.load_data() class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] # print the shape of the numpy arrays print ('Print shape of pixel data') print(x_train.shape) print ('Print shape of labels') print(y_train.shape) # Normalize pixel values to between 0 and 1 x_train = x_train.astype("float32") / 255.0 x_test = x_test.astype("float32") / 255.0 # choose an image num to display and print num = 20 image = x_train[num] label = y_train[num] print ('Print normailzed pixel data of image ',num, ' :') print(x_train[num]) print ('Print label of image ',num , ' :' ) print(y_train[num]) 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(x_train[i], cmap=plt.cm.binary) plt.xlabel(class_names[y_train[i]]) plt.show()