Abstract
MFF-Net (a multi-scale feature fusion convolutional neural network) was designed to improve the recognition rate of handwritten digits. The low-level, middle-level and high-level features of the image were first extracted through the convolution operation, and then the low-level and intermediate features were further extracted through different convolutional layers, later directly fused with the high-level features of the image with a certain weight, and then processed by the full connection layer. By adding a batch normalization layer before the activation layer, and a dropout layer between the full connection layers, the accuracy and generalization capacity of the network are improved. At the same time, a dynamic learning rate algorithm was designed, with which, the trained network accuracy was significantly improved as shown in the experiments on the MNIST data set. The accurate rate could reach 99.66% through only 30 epochs training. The comparison indicated that the accuracy of the network model is significantly higher than that of others.
Introduction
Handwritten digit recognition has wide range of applications in the era of big data especially in the fiscal, taxation, financial and other fields which need handwritten records and expect improved work efficiency through the realization of automatic recognition with the model. Thus, it is of great theoretical significance in the field of pattern recognition. Many scholars at home and abroad have proposed different algorithms for handwritten digit recognition and have achieved remarkable results. Zhong et al. [1] proposed a multi-scale neural network algorithm based on CNN, which directly conveys multiple features to the full connection layer and the Softmax classifier by dint of convolution and pooling operations, and finally achieves an accuracy of 99.20%. Zhao et al. [2] realized the recognition of handwritten digital images by calculating the shortest distance between the vectors, and achieved a recognition rate of more than 95%. Chen et al. [3] proposed a fusion convolutional neural network (F-CNN) model, which integrates the low-level, middle-level and high-level features, expands the size of the high-level network layer, then enhances the expression ability of the F-CNN model, and finally achieves a recognition rate of 99.10%. Zeng et al. [4] with a combination of an autoencoder and a convolutional neural network, designed a deep convolutional autoencoder neural network, which has achieved a recognition accuracy rate of 99.37%. Zhou et al. [5] designed an adaptive enhancement perceptron network mode with a multilayer perceptron as a base classifier, which uses an adaptive enhancement algorithm as an integration strategy and achieves an accuracy of 94.21%. Although the above-mentioned network models might provide promising recognition rate, the recognition rate is still far from ideal, and there is still room for improvement. In this study, we designed a multi-scale feature fusion convolutional neural network, and when training with a dynamic learning rate algorithm, we achieved an accuracy rate of 99.66%, which is 5.45 percentage points higher than that mentioned in the fifth reference.
MNIST data set
The MNIST data set is a widely used in the field of handwritten character recognition, which originates from the National Institute of Standards and Technology (NIST) [6]. The training set has handwritten digits from 250 different people, of which 50% are high school students, and the rest are from the Census Bureau. The test set has the same handwritten digit data source as the training set and it has a total of 60,000 samples, including 50,000 training set and 10,000 test set samples [7, 8, 9]. Each piece of data in the data set is composed of a digital image and a label. and each image is 28 by 28. Figure 1 shows 24 different forms of number 6 randomly selected in this data set.
Different forms of number six.
MFF-Net network model
PyTorch encapsulates the MNIST data set. Each piece of data is composed of a three-dimensional tensor image (1, 28, 28) and a label, which can be directly downloaded with Downloader.
The MFF-Net (Multi-scale Feature Fusion Net) network will add a batch standardization layer before each activation layer to speed up the convergence of the network and slow down the disappearance of the gradient, of which the batch standardization calculation is determined by Eq. (5). Equation (1) represents the number of this batch samples,
The images processed by the batch normalization layer directly use the Relu activation function, and the calculation method is shown in Eq. (6).
MFF-Net network model structure.
The MFF-Net network model is designed with nine layers in total, and the network model structure is shown in Fig. 2. The first layer of the model is the convolutional layer Conv1, which uses a 3 by 3 convolution kernel with a sliding step of 1 to extract low-level features of the image. The second layer is a convolutional layer Conv2, which uses a 3 by 3 convolution kernel with a sliding step of 1 to extract the intermediate features of the image. The third layer is the maximum pooling layer Max-Pool1 with a 2 by 2 pooling window and a sliding step of 2, and it is used to down-sample the image and reduce the dimensionality. The fourth layer is the convolutional layer Conv3, and the convolution kernel with a sliding step of 1 and the kernel size of 3 by 3 is used to extract the advanced features of the image. The fifth layer is the convolutional layer Conv4, and the kernel size is 3 by 3 with a sliding step of 1, which further extracts the advanced features of the image. The sixth layer is the pooling layer Max-Pool2 to further down-sample the image. The seventh layer is the full connection layer Fc with 2048 neurons and the eighth layer is the full connection layer Fc2 which has 1024 neurons. The ninth output layer is Fc2 with 10 neurons. The convolutional layer Conv1f and Conv2f extract the low-level and middle-level features of the image, and sent directly the features to the fusion layer with a certain weight, which could effectively prevent the fast loss of image features and solve the problem of fast gradient disappearance. The feature fusion method uses Eq. (7), where
In addition, a Dropout layer with a probability of 0.5 is added between every two layers of Fc1, Fc2, and Fc3 of the MFF-Net network model to further improve the generalization ability and recognition accuracy of the network model.
The loss function adopts cross-entropy loss. It is a good measure of the difference between two different probability distributions of the same random variable, which is expressed as the difference between the true probability distribution and the predicted probability distribution in machine learning [10, 11]. The smaller the value of cross entropy is, the smaller the difference between the true probability distribution and the predicted probability distribution is, and the better prediction effect the model has. When use Cross Entropy Loss to calculate Loss and use gradient descent to solve, the convex optimization problem has pretty good convergence characteristics. The mathematical expression of cross entropy is Eq. (8), where p represents the true probability and q represents the predicted probability.
Flow chart of dynamic learning rate algorithm.
In order to improve the accuracy of the model, the author designed a dynamic learning rate algorithm. Experiments showed that this algorithm for training could effectively improve the accuracy of the model. The algorithm flow chart is shown in Fig. 3, in which, the accuracy refers to the average accuracy rate of an epoch on the test set. The algorithm is described as follows:
To initialize lr: initialization is 0.1. To decide whether the accuracy rate decreases twice continuously. If YES, skip to step 3; if NO, continue the training with the current lr. lr
Numerous experiments and comparison show the learning rate adjustment algorithm in this paper achieves better performance. That’s shown in Fig. 4.
Learning rate adjustment method.
Experimental environment
For the hardware device, the computer has a CPU of Intel I5-10600KF with the 4.1 GHZ main frequency, a graphics card of GALAXY NVidia 3060. The computer is also equipped with Ubuntu20.04, 64-bit operating system, PyTorch 1.8, deep learning framework, CUDA11.2 parallel computing library and Python3.8.
MFF-Net network model parameters
In the training process, each batch will disrupt the order of the data and when each epoch training is completed, a prediction is made on the test set, on which, the accuracy rate on the test set is based. The dynamic learning rate algorithm adjust the learning rate of the model in line with the accuracy changes. The network model parameters are shown in Table 1.
MFF-Net network model parameter configuration table
MFF-Net network model parameter configuration table
Comparison of the two training methods
The model took 539.24 seconds to finish 30 Epoch trainings and finally reached an accuracy of 0.9966 on the test set. The initial network learning rate lr is set to 0.1, the Dropout probability 0.5,
The accuracy of the two training methods on the training set.
The loss of the two training methods on the training set.
In the experiment, the network model was trained and tested under the fixed learning rate and the automatic learning rate. The results show that the performance of the network could be significantly improved when the automatic learning rate was used for training. Figure 5 shows the relationship between the prediction accuracy and Epoch based on the training set. It can be seen that from the first to the 14th Epoch, the accuracy of the two training methods is basically the same, and from the subsequent 15th to the 30th Epoch, the training accuracy of the automatic learning rate is higher than that of the fixed learning rate. Figure 6 shows the loss of the two training methods on the training set. It is easy to find, from the 1st to the 14th Epoch, the loss of the two training methods is basically the same and from the following 15th to the 30th Epoch, the training loss using the automatic learning rate method is less than that of the fixed method. Figure 7 indicates the accuracy of the two training methods on the test set. From the image, when the automatic learning rate method is used for training, the accuracy fluctuates significantly at the beginning, but as the training deepens and the learning rate is adjusted, the shock tends to be stable, and the accuracy is further improved, while when the fixed learning rate method is used for training, the entire training process oscillates significantly and its accuracy rate is significantly worse than that of the training using the automatic learning rate method.
The accuracy of the two training methods on the test set
Recognition accuracy of different algorithms
The accuracy of the two training methods on the test set.
Comparison of accuracy of the two training methods on the test set.
Table 2 indicates the average accuracy, the maximum accuracy and the final accuracy of 30 epochs obtained by the two training methods on the test set. It can be seen from the data in the table and Fig. 8 that the training of automatic learning rate has edge over that of fixed learning rate training.
In this study, we compare the accuracy of the network model MFF-Net with other algorithms. It can be seen from the Table 3 that among the other eight algorithms, the algorithm referred in the fifth reference has the highest accuracy, being 99.37% and that in the sixth reference has the lowest accuracy rate of 94.21%. While the accuracy rate of MFF-Net is 96.66%, 5.45 percentage points higher than that proposed in Reference No. 6, and 0.29 percentage points higher than that mentioned in Reference No. 5. It is not hard to find that MFF-Net could effectively improve the accuracy of the network by fusing multiple features of the image.
Conclusion
In this paper, we designed a multi-scale feature fusion method featured by the fusion of the low-level, middle-level and high-level features of the image with a certain weight, which is automatically learned by the network, the addition of batch normalization layer before the activation layer, and a dropout layer between the full connection layers, which greatly speed up the convergence of the network and improve the generalization ability. At the same time, an automatic learning rate algorithm is designed used for training, which adjusts the learning rate dynamically in accordance with the result on the test data set and under which, training can improve the recognition accuracy of the network relatively smoothly. The experimental results show that the network model can reach a recognition rate of 99.66%, 0.29 to 5.45 percentage points higher than that proposed in References No. 2-No. 9. There is still a certain room for improvement in its accuracy for only 30 Epochs are trained. It is expected, with this model, automatic recognition could be realized in fiscal, taxation, financial and other fields which need handwritten records so as to save time and improve work efficiency. The future study will explore a combination of MFF-NET and Google Inception models, which can better extract features, thus, greater recognition performance can be anticipated.
Footnotes
Acknowledgments
This work was partly supported by the General project of Anhui Natural Science Foundation (No. 1808085MF171).
