DL3
DL3
import keras
import numpy as np
fashion_mnist = keras.datasets.fashion_mnist
print(train_labels.shape)
# Training Data
train_images.shape
for i in range(25):
plt.subplot(5, 5, i + 1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.xlabel(class_names[train_labels[i]])
plt.show
# Set up Layers
model = keras.Sequential([
keras.layers.MaxPooling2D(pool_size=(2, 2)),
keras.layers.Flatten(),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
model.summary()
# Compile the model
# predictions = probability_model.predict(test_images)
predictions = model.predict(test_images)
plt.grid(False)
plt.xticks([])
plt.yticks([])
plt.imshow(img, cmap=plt.cm.binary)
predicted_label = np.argmax(predictions_array)
if predicted_label == true_label:
color = 'blue'
else:
color = 'red'
100*np.max(predictions_array),
class_names[true_label]),
color=color)
# Let us plot the predictions, red means incorrect while blue means correct prediction.
rows = 5
cols = 3
for i in range(total_images):
plt.subplot(rows, cols, i + 1)
plt.tight_layout()
plt.show()