A simple CNN model based on Keras API
I followed and implemented the LeNet-5 CNN architecture by Keras API, then trained the model by MNIST dataset. The test loss is 0.035 and the test accuracy is 0.989 after evaluating.(For more specific training and testing process, it is on 2DCNN_MNIST_digit.py) After that, I serach some digits verification code on the internet and decide to get further result on the performance of my model. Unfortunately, the performance is not good. I guess the main problem is the difference between MNIST and other digits in their art styles.
Layer (type) | Output Shape | Param # |
---|---|---|
conv2d (Conv2D) | (None, 28, 28, 6) | 156 |
average_pooling2d (AveragePooling2D) | (None, 14, 14, 6) | 0 |
conv2d_1 (Conv2D) | (None, 10, 10, 16) | 2416 |
average_pooling2d_1 (Averag ePooling2D) | (None, 5, 5, 16) | 0 |
flatten (Flatten) | (None, 400) | 0 |
dense (Dense) | (None, 120) | 48120 |
dense_1 (Dense) | (None, 84) | 10164 |
dense_2 (Dense) | (None, 10) | 850 |
Total params: 61,706
Trainable params: 61,706
Non-trainable params: 0
Software | Version |
---|---|
Python | 3.9.9 |
Numpy | 1.21.4 |
tensorflow | 2.7.0 |
keras | 2.7.0 |
matplotlib | 3.5.0 |
Y. Lecun, L. Bottou, Y. Bengio and P. Haffner, "Gradient-based learning applied to document recognition," in Proceedings of the IEEE, vol. 86, no. 11, pp. 2278-2324, Nov. 1998, doi: 10.1109/5.726791.