Poor Performance with CNN Model on MNIST Dataset

I am currently a computer science student and for my Machine Learning class, I have been assigned a project. I chose to use a CNN model and I am working with the MNIST dataset. However, I am facing an issue where the model’s performance is unexpectedly low – I am getting an accuracy of just 0.0664.

Below is the code for my model:

model = Sequential()
model.add(Conv2D(32, kernel_size=(5, 5), strides=(1, 1), padding="same", kernel_initializer='glorot_uniform', input_shape=(64, 64, 1), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2), padding="same"))
model.add(Dense(1024, activation='relu'))
model.add(Dense(num_classes, activation='softmax'))
model.compile(optimizer = Adam(learning_rate = 0.01), loss = 'categorical_crossentropy', metrics = ['accuracy'])
model1 = model.fit(x_train, y_train,batch_size=128, epochs=20)

I appreciate any suggestions or insights on how I can improve the performance. Thanks in advance!

>Solution :

A potential improvement could come from reducing the size of your Dense layer. Try minimizing the number of units in your Dense layer to 64 instead of 1024. Update your model with:

model.add(Dense(64, activation='relu'))

Leave a Reply