<jupyter_start><jupyter_text>Load mnist dataset<jupyter_code>fashion_mnist = keras.datasets.fashion_mnist
(X_train_full, Y_train_full), (X_test, Y_test) =fashion_mnist.load_data()
class_name =["T-shirt/top", " Trouser", " Pullower", "Dress", "Coat","sandal", "Shirt", "Sneaker", "Bag","Ankel oot"]<jupyter_output><empty_output><jupyter_text>Data reshape<jupyter_code>X_train_full = X_train_full.reshape((60000, 28, 28, 1))
X_test = X_test.reshape((10000, 28, 28, 1))<jupyter_output><empty_output><jupyter_text>Data normalization<jupyter_code>X_train_n = X_train_full / 255.
X_test_n = X_test / 255.
X_valid, X_train = X_train_n[:5000], X_train_n[5000:]
Y_valid, Y_train = Y_train_full[:5000], Y_train_full[5000:]
X_test = X_test_n<jupyter_output><empty_output><jupyter_text>create model architecture<jupyter_code>np.random.seed(42)
tf.random.set_seed(42)<jupyter_output><empty_output><jupyter_text>create model cnn<jupyter_code>model = keras.models.Sequential()
model.add(keras.layers.Conv2D(filters= 32, kernel_size= (3,3), strides=1, padding='valid', activation='relu', input_shape=(28, 28, 1)))
model.add(keras.layers.MaxPool2D((2, 2)))

model.add(keras.layers.Flatten())
model.add(keras.layers.Dense(300, activation="relu"))
model.add(keras.layers.Dense(100, activation="relu"))
model.add(keras.layers.Dense(10, activation="softmax"))
model.summary()
model.compile(loss="sparse_categorical_crossentropy",
              optimizer="sgd",
              metrics=["accuracy"])
model_history = model.fit(X_train, Y_train, epochs=10, batch_size= 64,
                          validation_data=(X_valid, Y_valid))
model_history.history
pd.DataFrame(model_history.history).plot(figsize=(8,5))
plt.grid(True)
plt.gca().set_ylim(0,1)

plt.show()
ev = model.evaluate(X_test_n, Y_test)
ev
X_new =X_test[:3]
predict_x=model.predict(X_new) 
classes_x=np.argmax(predict_x,axis=1)
Y_test[:3]
print(plt.imshow(X_test[5].reshape((28, 28))))
keras.backend.clear_session<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16145307769929365, 'fraction_numerical': 0.04238143289606458, 'mean_word_length': 7.852678571428571, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '245417', 'license': 'MIT', 'n_tokens_mistral': 865, 'n_tokens_neox': 794, 'n_words': 99, 'path': 'Fashion_MNIST_using_CNN.ipynb', 'repo_name': 'saurabhpojhi/Fashion-MNIST-using-CNN-Deep-Learning', 'size': '1982'}