I'm a bit new when it comes to CNN, so please correct me wherever possible!
I've been experimenting with the MNIST dataset for digit classification. I decided to take it one step further by passing my own handwritten digit into the predict method of the model. I am aware that the MaxPooling2D layer only allows fixed input resolution, so after some research, I used GlobalMaxPooling2D. This solved the problem of variable input image resolution. The problem I am facing right now, is that the predict method accurately predicts images from the test set of the MNIST dataset, but is unable to predict my own handwritten digits. This is my Model:
model=Sequential()
model.add(Conv2D(128,(5,5),input_shape=(None,None,1), data_format='channels_last'))
model.add(Dense(80, activation='relu'))
model.add(GlobalMaxPooling2D())
model.add(BatchNormalization())
model.add(Dense(10,activation='softmax'))
The model gives a training accuracy of 94.98% and a testing accuracy of 94.52%. For predicting my own handwritten digit, I used an image of resolution 200x200. The model somehow can predict specific digits like 8, 6 and 1, but when I test any other digit, it still classifies it into 8, 6 or 1. Can anyone please point out where I'm going wrong? Any help is appreciated!
Conv2DtoDensewithout transforming the 2D spatial information into 1D forDensewill throw a inconsistent dimension error. Did you meant to switch the Global Max Pooling with the Dense? - rayryeng