Find the below working code
import tensorflow as tf
from tensorflow.keras.models import Sequential
import matplotlib.pyplot as plt

(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()

x_train = x_train.reshape(60000,28,28,1).astype('float32')
x_test = x_test.reshape(10000,28,28,1).astype('float32')

number_class=10
y_train = tf.keras.utils.to_categorical(y_train)
y_test = tf.keras.utils.to_categorical(y_test)

x_train =x_train/255.0
x_test =x_test/255.0

model = Sequential()
model.add(tf.keras.layers.Conv2D(32, (3, 3), activation='relu',  input_shape=(28, 28, 1)))
model.add(tf.keras.layers.MaxPooling2D((2, 2)))
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(100, activation='relu'))
model.add(tf.keras.layers.Dense(10, activation='softmax'))

# compile model
opt = tf.keras.optimizers.SGD(learning_rate=0.01, momentum=0.9)
model.compile(optimizer=opt, loss='categorical_crossentropy', metrics=['accuracy'])

model.fit(x_train,y_train, batch_size=128, epochs=15, verbose=1, validation_data=(x_test,y_test))

Output
Epoch 1/15
469/469 [==============================] - 28s 59ms/step - loss: 0.3982 - accuracy: 0.8846 - val_loss: 0.2052 - val_accuracy: 0.9390
Epoch 2/15
469/469 [==============================] - 27s 57ms/step - loss: 0.1612 - accuracy: 0.9515 - val_loss: 0.1256 - val_accuracy: 0.9629
Epoch 3/15
469/469 [==============================] - 26s 56ms/step - loss: 0.1155 - accuracy: 0.9651 - val_loss: 0.1013 - val_accuracy: 0.9692
Epoch 4/15
469/469 [==============================] - 27s 57ms/step - loss: 0.0900 - accuracy: 0.9730 - val_loss: 0.0860 - val_accuracy: 0.9737
Epoch 5/15
469/469 [==============================] - 26s 56ms/step - loss: 0.0725 - accuracy: 0.9782 - val_loss: 0.0807 - val_accuracy: 0.9748
Epoch 6/15
469/469 [==============================] - 26s 55ms/step - loss: 0.0615 - accuracy: 0.9815 - val_loss: 0.0812 - val_accuracy: 0.9735
Epoch 7/15
469/469 [==============================] - 26s 55ms/step - loss: 0.0529 - accuracy: 0.9841 - val_loss: 0.0687 - val_accuracy: 0.9788
Epoch 8/15
469/469 [==============================] - 26s 56ms/step - loss: 0.0458 - accuracy: 0.9859 - val_loss: 0.0604 - val_accuracy: 0.9806
Epoch 9/15
469/469 [==============================] - 30s 64ms/step - loss: 0.0410 - accuracy: 0.9873 - val_loss: 0.0570 - val_accuracy: 0.9807
Epoch 10/15
469/469 [==============================] - 27s 58ms/step - loss: 0.0372 - accuracy: 0.9887 - val_loss: 0.0559 - val_accuracy: 0.9816
Epoch 11/15
469/469 [==============================] - 25s 53ms/step - loss: 0.0327 - accuracy: 0.9897 - val_loss: 0.0625 - val_accuracy: 0.9792
Epoch 12/15
469/469 [==============================] - 25s 54ms/step - loss: 0.0282 - accuracy: 0.9919 - val_loss: 0.0511 - val_accuracy: 0.9839
Epoch 13/15
469/469 [==============================] - 26s 55ms/step - loss: 0.0256 - accuracy: 0.9924 - val_loss: 0.0558 - val_accuracy: 0.9831
Epoch 14/15
469/469 [==============================] - 26s 56ms/step - loss: 0.0232 - accuracy: 0.9929 - val_loss: 0.0542 - val_accuracy: 0.9829
Epoch 15/15
469/469 [==============================] - 27s 57ms/step - loss: 0.0208 - accuracy: 0.9940 - val_loss: 0.0516 - val_accuracy: 0.9835