Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Fig. 1 illustrates an application environment of a handwriting model training method provided by an embodiment of the present invention. The application environment of the handwriting model training method comprises a server and a client, wherein the server and the client are connected through a network, the client is equipment capable of performing man-machine interaction with a user and comprises but is not limited to equipment such as a computer, a smart phone and a tablet, and the server can be specifically realized by an independent server or a server cluster consisting of a plurality of servers. The handwriting model training method provided by the embodiment of the invention is applied to a server.
As shown in fig. 2, fig. 2 is a flow chart of a handwriting model training method in the embodiment of the present invention, where the handwriting model training method includes the following steps:
s10: and acquiring a pixel value characteristic matrix of each Chinese character in the Chinese character training sample to be processed by adopting an optical character recognition technology.
The Optical Character Recognition technology (OCR) refers to converting characters on an image into computer-editable Character contents, and a to-be-processed Chinese Character training sample refers to an initially-obtained and unprocessed training sample. The pixel value feature matrix is a matrix that uses pixel values as features and is expressed in a matrix manner.
In this embodiment, an OCR technology is adopted to perform operations such as positioning, segmentation, feature extraction, and the like on characters on an image, and obtain a pixel value feature matrix of each character in a training sample of characters to be processed, where the pixel value feature matrix can be directly read and recognized by a computer, and can extract pixel value features of the training sample of characters to be processed, and represent the extracted pixel value features by using a matrix.
S20: and acquiring a standard Chinese character training sample based on the pixel value characteristic matrix of each Chinese character in the Chinese character training sample to be processed.
The standard Chinese character training sample refers to a training sample obtained according to a standard character (such as a character belonging to a regular script, a song script, an clerical script or the like, and a regular script or a song script is selected as a common font), and the character in the Chinese character training sample to be processed belongs to the standard character.
In this embodiment, based on the pixel value feature matrix of each Chinese character in the Chinese character training samples to be processed, a standard Chinese character training sample for training a convolutional neural network is obtained, so as to improve the efficiency of network training. The standard Chinese character training sample is obtained from a standard character belonging to a Chinese character font such as a regular script, a song script or an clerical script, and the song script is taken as an example for explanation in the embodiment. It should be understood that the standard word herein refers to a word belonging to a mainstream font in a current chinese font, such as a word of a default font song body in an input method of a computer device, a word of a mainstream font regular font commonly used for copying, and the like; characters with Chinese characters, such as cursive script characters and round characters, which are rarely used in daily life, are not listed in the standard characters.
S30: a convolutional neural network is initialized.
In one embodiment, initializing a convolutional neural network comprises: make the weight value initialized by the convolution neural network satisfy the formula
Wherein n is
l Represents the number of samples of training samples input at the l-th layer, S () represents a variance operation, W
l Represents the weight of the l-th layer, is>
Denoted arbitrary, l denotes the l-th layer in a convolutional neural network.
The Convolutional Neural Network (CNN) is a feed-forward Neural Network, and its artificial neurons can respond to peripheral units in a part of coverage range, and can perform image processing and recognition. The convolutional Neural network is mainly different from a general Deep Neural Network (DNN) in that the convolutional Neural network includes a convolutional layer and a pooling layer, which provides an important technical support for the convolutional Neural network to process and identify images with texts.
The convolutional neural network comprises the weight and the bias of the connection of each neuron between each layer, and the weight and the bias determine the recognition effect of the convolutional neural network.
In this embodiment, the convolutional neural network is initialized, and the initialization operation is to set initial values of weights and biases in the convolutional neural network. Specifically, let C l The convolution of the l-th layer in the convolutional neural network of (1), C is known from the properties of the convolutional neural network l =W l x l +b l Wherein W is l Represents the weight, x, of the l-th layer l Training samples for initialization representing the l-th layer input, b l Indicating the bias of the l-th layer. Then C is l The variance of (C) can be found to be S (C) l )=n l S(W l x l ) Where S () represents a variance operation, n l The number of samples of the training samples input at the l-th layer is represented. When the convolutional neural network is trained, the average value of the weight values is too large, which may result in too large gradient, and the minimum value of the error function cannot be found effectively, so that if the weight value W is set to satisfy the average value 0, C is described above l The variance expression of (C) can be further written as S (C) l )=n l S(W l )E((x l ) 2 ) Where E () represents the mathematically expected operation.
In particular, the convolutional layer in the convolutional neural network uses a recirculation (Rectified Linear Unit, which is called Linear rectification function) as an activation function, which is also called a modified Linear Unit, and is a commonly used activation function in an artificial neural network, and usually refers to a nonlinear function represented by a ramp function and a variant thereof. X can be derived from the activation function ReLU
l =ReLU(C
l-1 ) And
substituting these two equations into C
l Variance expression of (C)
l )=n
l S(W
l )E((x
l )
2 ) Get->
During the training of the convolutional neural network, the variance should be kept consistent as much as possible, so that the problem that the gradient convergence is too fast or too slow due to the fact that the variance becomes larger and smaller in the training process cannot be caused, and therefore the problem that the minimum value of the error function cannot be found effectively or the training speed is too slow can not be caused. Therefore, in order to keep the variance consistent, it is based on the above equation @>
It can be known that the weights should beSatisfy +>
Representing arbitrary, the weights of the convolutional neural network can be set accordingly according to the formula. The offset may be set to a smaller value at initial setup, such as in the interval [ -0.3,0.3]In the meantime.
The convolutional neural network is initialized reasonably, so that the network has flexible adjustment capability in the initial stage, the network can be adjusted effectively in the training process, the minimum value of an error function can be found quickly and effectively, the updating and the adjustment of the convolutional neural network are facilitated, and the model obtained by model training based on the convolutional neural network has accurate recognition effect when Chinese handwriting recognition is carried out.
S40: and inputting the standard Chinese character training sample into a convolutional neural network for training, updating the weight and the bias of the convolutional neural network by adopting a back propagation algorithm based on random gradient descent, and obtaining a standard Chinese character recognition model.
The random Gradient Descent (SGD for short) is a processing method for acquiring an error generated by each training sample in a training process when updating a network parameter, and randomly adopting the error generated by a single sample in the training process for multiple times to update the network parameter. A Back Propagation algorithm (BP algorithm for short) is a training and learning method in neural network learning, and is used to adjust the weight and bias between nodes in the neural network. When the weight and the bias in the neural network are adjusted by using the back propagation algorithm, the minimum value of the error function needs to be obtained, and in the embodiment, the minimum value of the error function is specifically obtained by using a processing method of random gradient descent.
In this embodiment, the standard chinese character training samples are input to the convolutional neural network for training, and the weight and bias of the convolutional neural network are updated by using a back propagation algorithm based on stochastic gradient descent, so as to obtain a standard chinese character recognition model. The standard Chinese character recognition model learns deep characteristics of a standard Chinese character training sample in a training process, so that the model can accurately recognize standard characters and has the recognition capability of the standard characters. It should be noted that, no matter what the standard Chinese character training sample adopts the standard characters corresponding to other Chinese characters such as regular script, song script, clerical script and the like, because the standard characters have small differences in the aspect of character recognition, the standard Chinese character recognition model can accurately recognize the standard characters corresponding to the characters such as regular script, song script, clerical script and the like, and obtain a more accurate recognition result.
S50: acquiring an irregular Chinese character training sample, inputting the irregular Chinese character training sample into a standard Chinese character recognition model for training, updating the weight and the bias of the standard Chinese character recognition model by adopting a backward propagation algorithm based on random gradient descent, and acquiring and adjusting the Chinese handwritten character recognition model.
The non-standard Chinese character training sample refers to a training sample obtained according to a handwritten Chinese character, and the handwritten Chinese character can be a character obtained in a handwriting mode according to the font form of a standard character corresponding to a font such as a regular script, a song script, an clerical script and the like. It will be appreciated that the non-canonical Chinese training sample differs from the canonical Chinese training sample in that the non-canonical Chinese training sample is obtained from handwritten Chinese, and since it is handwritten, of course contains a variety of different font styles.
In this embodiment, the server obtains an irregular chinese character training sample, where the training sample includes characteristics of a handwritten chinese character, inputs the irregular chinese character training sample into a standard chinese character recognition model for training and adjustment, and updates a weight and an offset of the standard chinese character recognition model by using a back propagation algorithm based on stochastic gradient descent to obtain an adjusted chinese character handwriting recognition model. It will be appreciated that the canonical Chinese character recognition model has the ability to recognize standard canonical Chinese characters, but does not have high recognition accuracy when recognizing handwritten Chinese characters. Therefore, the embodiment trains by adopting the non-standard Chinese character training sample, so that the standard Chinese handwritten character recognition model adjusts parameters (weight and bias) in the model on the basis of the existing recognition standard Chinese character, and obtains the adjusted Chinese handwritten character recognition model. The adjusted Chinese handwriting recognition model learns deep features of handwritten Chinese characters on the basis of the original recognition standard characters, the Chinese handwritten character recognition model is combined with deep features of standard characters and handwritten Chinese characters, the standard characters and the handwritten Chinese characters can be effectively recognized at the same time, and a recognition result with high accuracy is obtained.
The convolutional neural network judges according to the pixel distribution of the character when recognizing the character, the handwritten Chinese character in real life has a difference with the standard character, but the difference is much smaller than the difference of the handwritten Chinese character and the standard character which does not correspond to the standard character, for example, the difference between the pixel distribution of the handwritten Chinese character and the pixel distribution of the standard character is much smaller than the difference between the pixel distribution of the handwritten Chinese character and the pixel distribution of the standard character. It can be considered that even if there is a certain difference between the handwritten Chinese character and the corresponding standard character, the difference is much smaller than that of the standard character which does not correspond, and therefore, the recognition result can be determined by the most similar (i.e., the difference is the smallest) principle. The Chinese handwriting character adjusting recognition model is obtained by convolutional neural network training, combines the deep characteristics of standard characters and handwritten Chinese characters, and can effectively recognize the handwritten Chinese characters according to the deep characteristics.
For steps S40 and S50, the back propagation algorithm based on stochastic gradient descent is used to update the error back propagation, so that model training can be performed smoothly even if the number of training samples is large, and the efficiency and effect of network training can be improved, so that training is more effective.
It should be noted that the order of step S40 and step S50 in this embodiment is not interchangeable, and step S40 is executed first and then step S50 is executed. The convolutional neural network is trained by adopting the standard Chinese training sample, so that the obtained standard Chinese character recognition model has better recognition capability, and has accurate recognition result on the standard character. The fine tuning of the step S50 is performed on the basis of good recognition capability, so that the adjusted Chinese handwriting recognition model obtained by training can effectively recognize the handwritten Chinese according to the deep features of the learned handwritten Chinese, and the handwritten Chinese recognition model has a relatively accurate recognition result. If step S50 is executed first or only step S50 is executed, because the handwritten Chinese characters have various forms, the features learned by directly training the handwritten Chinese characters cannot well reflect the features of the handwritten Chinese characters, so that the model is "bad" at the beginning, and it is difficult to have an accurate recognition result for the handwritten Chinese character recognition after how to adjust the model. Although everyone has different handwritten Chinese characters, most of the handwritten Chinese characters are similar to standard characters (for example, the handwritten Chinese characters imitate the standard characters). Therefore, the model training according to the standard characters at first is more in line with objective conditions, the effect is better than that of directly performing the model training on the handwritten Chinese characters, corresponding adjustment can be performed under a 'good' model, and the adjusted Chinese handwritten character recognition model with high handwritten Chinese character recognition rate is obtained.
S60: obtaining a Chinese character sample to be tested, adopting an adjusted Chinese character handwriting recognition model to recognize the Chinese character sample to be tested, obtaining error characters of which the recognition results do not accord with the real results, and taking all the error characters as error character training samples.
The Chinese character sample to be tested is a training sample for testing obtained according to the standard characters and the handwritten Chinese characters, and the standard characters adopted in the step are the same as the standard characters used for training in the step S40 (because each character corresponding to the fonts such as regular script, song script and the like is uniquely determined); the handwritten Chinese characters used may be different from the handwritten Chinese characters used for training in step S50 (the handwritten Chinese characters of different people are not identical, each character corresponding to the handwritten Chinese characters may correspond to a plurality of font forms, and in order to distinguish from the non-standard Chinese character training samples used for training in step S50 and avoid the situation of over-fitting of model training, the handwritten Chinese characters different from step S50 are generally used in this step).
In this embodiment, the trained adjusted chinese handwriting recognition model is used to recognize a chinese sample to be tested, where the chinese sample to be tested includes a standard word and a preset label value (i.e., a real result) thereof, and a handwritten chinese word and a preset label value thereof. The standard characters and the handwritten Chinese characters can be input into the adjusted Chinese handwritten character recognition model in a mixed mode during training. When the Chinese character sample to be tested is recognized by adopting the adjusted Chinese handwritten character recognition model, the corresponding recognition result is obtained, and all wrong characters of which the recognition result is not consistent with the label value (real result) are taken as the wrong character training samples. The error character training sample reflects the problem that the recognition precision of the Chinese character handwriting recognition model is still insufficient, so that the Chinese character handwriting recognition model can be further updated, optimized and adjusted according to the error character training sample.
Since the recognition accuracy of the adjusted Chinese handwritten character recognition model is actually influenced by both the normalized Chinese character training samples and the non-normalized Chinese character training samples, on the premise that the network parameters (weight and offset) are updated by the normalized Chinese character training samples, and then the network parameters (weight and offset) are updated by the non-normalized Chinese character training samples, the obtained adjusted Chinese handwritten character recognition model can be caused to excessively learn the characteristics of the non-normalized Chinese character training samples, so that the obtained adjusted Chinese handwritten character recognition model has very high recognition accuracy on the non-normalized Chinese character training samples (including handwritten Chinese characters), but excessively learns the characteristics of the non-normalized Chinese character samples, and influences the recognition accuracy of the handwritten Chinese characters except the non-normalized Chinese character training samples, therefore, the step S60 adopts the Chinese character samples to be tested to recognize the adjusted Chinese handwritten character recognition model, and can greatly eliminate the excessive learning of the non-normalized Chinese character training samples adopted during training. The Chinese handwriting recognition model is adjusted to recognize the Chinese character sample to be tested so as to find out the error generated by over-learning, and the error can be reflected by the error word, so that the network parameters of the Chinese handwriting recognition model can be further updated, optimized and adjusted according to the error word.
S70: and inputting the error word training sample into the adjusted Chinese handwritten word recognition model for training, and updating the weight and the bias of the adjusted Chinese handwritten word recognition model by adopting a back propagation algorithm based on batch gradient descent to obtain a target Chinese handwritten word recognition model.
In this embodiment, the training samples of the erroneous character are input to the adjusted chinese handwritten character recognition model for training, and the training samples of the erroneous character reflect the problem of inaccurate recognition when the adjusted chinese handwritten character recognition model recognizes handwritten chinese characters other than the non-standard chinese handwritten character training samples due to the fact that the characteristics of the non-standard chinese character training samples are over-learned when the adjusted chinese handwritten character recognition model is trained. Moreover, due to the fact that the standard Chinese character training samples are adopted firstly and then the non-standard Chinese character training samples are adopted to train the model, the characteristics of the originally learned standard characters can be weakened excessively, and therefore the 'frame' which is initially built by the model and used for identifying the standard characters can be influenced. The problems of over-learning and over-weakening can be well solved by utilizing the error word training sample, and the adverse effects caused by over-learning and over-weakening generated in the original training process can be eliminated to a great extent according to the problem of recognition accuracy reflected by the error word training sample. Specifically, a backward propagation algorithm based on batch gradient descent is adopted when the error character training sample is adopted for training, the weight and the bias of the Chinese handwritten character recognition model are updated and adjusted according to the algorithm, and the target Chinese handwritten character recognition model is obtained and is a model which is finally trained and can be used for recognizing Chinese handwritten characters. When network parameters are updated, the sample capacity of error word training samples is small (error words are small), errors generated by all error word training samples during convolutional neural network training can be updated in a back propagation mode based on batch gradient descent, the fact that all generated errors can adjust and update the network is guaranteed, the convolutional neural network can be trained comprehensively, and the recognition accuracy of a target Chinese handwritten word recognition model is improved.
It should be noted that, in this embodiment, steps S40 and S50 adopt a back propagation algorithm based on random gradient descent; step S70 employs a back propagation algorithm based on batch gradient descent.
In step S40, the process of updating the weight and bias of the convolutional neural network by using the back propagation algorithm based on stochastic gradient descent specifically includes the following steps:
acquiring a binarization pixel value feature matrix corresponding to each training sample (each character) in a standard Chinese character training sample, randomly inputting each binarization pixel value feature matrix into a convolutional neural network to obtain each corresponding forward output, calculating an error between each forward output and a corresponding label value (real result), and correspondingly performing gradient descent back propagation once each error is acquired, and updating the weight and the bias of the network. Repeating the process of calculating each error and adopting each error to update the weight and the bias of the network until the error is less than the iteration stop threshold epsilon 1 And ending the circulation to obtain the updated weight and bias to obtain the standard Chinese character recognition model.
The process of updating the weight and the bias of the convolutional neural network by adopting the back propagation algorithm based on the stochastic gradient descent in the step S50 is similar to the process of the step S40, and is not described again here.
In step S70, the process of updating the weight and the bias of the convolutional neural network by using the back propagation algorithm based on the batch gradient descent specifically includes the following steps:
obtaining a binarization pixel value characteristic matrix corresponding to one training sample in error word training samples, inputting the binarization pixel value characteristic matrix into an adjusted Chinese handwritten word recognition model (essentially also a convolutional neural network) to obtain forward output, calculating the error between the forward output and a real result, obtaining and sequentially inputting the binarization pixel value characteristic matrices corresponding to the rest training samples into the adjusted Chinese handwritten word recognition model, calculating the error between the corresponding forward output and the real result, accumulating the errors to obtain the total error of the adjusted Chinese handwritten word recognition model for the error word training samples, adopting the total error to perform one-time gradient-descent-based back propagation, and updating the weight and bias of the networkRepeating the above processes of calculating total error and updating weight and bias of network by using total error until the error is less than stop iteration threshold epsilon 2 And then ending the circulation to obtain the updated weight and bias, thus obtaining the target Chinese handwritten character recognition model.
It can be understood that, for steps S40 and S50, because the number of training samples used for model training is huge, if a back propagation algorithm based on batch gradient descent is used, the efficiency and effect of network training will be affected, and even model training cannot be performed normally, and it is difficult to perform effective training. The efficiency and effect of network training can be improved by adopting a back propagation algorithm based on random gradient descent to update error back propagation, so that the training is more effective.
In step S70, the error word training samples have a small sample capacity (fewer error words), and the back propagation algorithm based on batch gradient descent can update the back propagation of all errors generated by the error word training samples during the convolutional neural network training, so that it is ensured that all errors generated can adjust and update the network, and the convolutional neural network can be trained comprehensively. Compared with a back propagation algorithm based on random gradient descent, the back propagation algorithm based on batch gradient descent is standard in gradient and can train a convolutional neural network comprehensively; the latter randomly extracts one training sample from the training samples each time to update the parameters of the network, and the gradient of the parameters is approximate and not standard, and is not as accurate as the former in training. The accuracy of model training can be improved by adopting a back propagation algorithm based on batch gradient descent, so that a target Chinese handwritten character recognition model obtained by training has accurate recognition capability.
In steps S10-S70, an optical character recognition technology is adopted to obtain a pixel value feature matrix of each Chinese character in the Chinese character training sample to be processed, and a standard Chinese character training sample is obtained based on the pixel value feature matrix of each Chinese character in the Chinese character training sample to be processed, wherein the standard Chinese character training sample can be directly recognized and read by a computer. And then initializing the convolutional neural network, which is favorable for improving the training efficiency of the neural network. The method is characterized in that a standard Chinese character training sample is adopted for training and acquiring a standard Chinese character recognition model, and then the standard Chinese character recognition model is updated in an adjusting mode through non-standard Chinese characters, so that the adjusted Chinese handwritten character recognition model acquired after updating learns deep features of handwritten Chinese characters in a training and updating mode on the premise of having the capability of recognizing standard characters, and the adjusted Chinese handwritten character recognition model can better recognize the handwritten Chinese characters. And then, recognizing the Chinese character sample to be tested by adopting the adjusted Chinese handwritten character recognition model, acquiring error characters of which the recognition result is not consistent with the real result, inputting all the error characters serving as error character training samples into the adjusted Chinese handwritten character recognition model for training and updating, and acquiring the target Chinese handwritten character recognition model. By adopting the error word training sample, the adverse effects caused by excessive learning and excessive weakening generated in the original training process can be eliminated to a great extent, and the recognition accuracy can be further optimized. The training of the standard Chinese character recognition model and the adjustment of the Chinese character handwriting recognition model adopt a backward propagation algorithm based on random gradient descent, and a better training effect can still be achieved under the condition of a large number of training samples. The Chinese handwritten character recognition model of the training target adopts a back propagation algorithm based on batch gradient descent, the parameters in the model can be fully updated by adopting the batch gradient descent, errors generated by the training sample in the training process are updated in a back propagation mode, the parameters are comprehensively updated according to the generated errors, and the recognition accuracy of the obtained model is improved.
In an embodiment, as shown in fig. 3, in step S20, the method for obtaining a standard chinese character training sample based on a pixel value feature matrix of each chinese character in a chinese character training sample to be processed specifically includes the following steps:
s21: acquiring a pixel value characteristic matrix of each Chinese character in a Chinese character training sample to be processed, and carrying out normalization processing on each pixel value in the pixel value characteristic matrix to acquire a normalized pixel value characteristic matrix of each Chinese character, wherein the formula of the normalization processing is
MaxValue is the maximum value of the pixel values in the pixel value characteristic matrix of each Chinese character, minValue is the minimum value of the pixel values in the pixel value characteristic matrix of each Chinese character, x is the pixel value before normalization, and y is the pixel value after normalization.
In this embodiment, a pixel value feature matrix of each chinese character in a chinese character training sample to be processed is obtained, where the pixel value feature matrix of each chinese character represents a feature of a corresponding word, and here, a pixel value represents a feature of a word, and since a word is represented based on two dimensions (generally, one word is represented by an m × n image), a pixel value can be represented by a matrix, that is, a pixel value feature matrix is formed. The computer device can identify the form of the pixel value feature matrix and read the numerical values in the pixel value feature matrix. After the server side obtains the pixel value characteristic matrix, the server side performs normalization processing on the pixel value of each Chinese character in the characteristic matrix by adopting a normalization processing formula to obtain the normalization pixel value characteristic of each Chinese character. In this embodiment, the normalization processing mode is adopted to compress the pixel value feature matrix of each Chinese character in the same range interval, so that the calculation related to the pixel value feature matrix can be accelerated, and the training efficiency of the Chinese character recognition model in the training specification can be improved.
S22: dividing pixel values in the normalized pixel value feature matrix of each Chinese character into two types of pixel values, establishing a binarization pixel value feature matrix of each Chinese character based on the two types of pixel values, and combining the binarization pixel feature matrices of each Chinese character to serve as a standard Chinese character training sample.
In this embodiment, the pixel values in the normalized pixel value feature matrix of each chinese character are divided into two types of pixel values, where the two types of pixel values refer to pixel values that only include a pixel value a or a pixel value B. Specifically, the pixel value greater than or equal to 0.5 in the normalized pixel feature matrix may be taken as 1, and the pixel value less than 0.5 may be taken as 0, to establish a corresponding binarized pixel value feature matrix of each chinese character, where the original pixel value in the binarized pixel feature matrix of each chinese character only contains 0 or 1. After the binarization pixel value feature matrix of each Chinese character is established, chinese character combinations corresponding to the binarization pixel value feature matrix are used as standard Chinese character training samples. For example, in an image containing a word, a portion containing a word pixel and a portion containing a blank pixel. The pixel values on a word are typically darker in color, with a "1" in the binary pixel value feature matrix representing a portion of a word pixel and a "0" representing a portion of a blank pixel in the image. It can be understood that the feature representation of the Chinese character can be further simplified by establishing the binary pixel value feature matrix, each Chinese character can be represented and distinguished only by adopting the matrices of 0 and 1, the speed of processing the feature matrix of the Chinese character by a computer can be increased, and the training efficiency of the Chinese character recognition model in the training specification can be further improved.
S21-S22, normalization processing is carried out on Chinese character training samples to be processed, binary pixel value feature matrixes of each Chinese character are obtained, characters corresponding to the binary pixel value feature matrixes of each Chinese character are used as standard Chinese character training samples, and the time for training the standard Chinese character recognition model can be shortened remarkably.
In an embodiment, as shown in fig. 4, in step S40, the standard chinese character training sample is input into the convolutional neural network for training, and the weight and bias of the convolutional neural network are updated by using a back propagation algorithm based on stochastic gradient descent, so as to obtain a standard chinese character recognition model, which specifically includes the following steps:
s41: and inputting the standard Chinese character training sample into the convolutional neural network, and obtaining the forward output of the standard Chinese character training sample in the convolutional neural network.
The convolutional neural network is a feed-forward neural network, and artificial neurons of the convolutional neural network can respond to peripheral units in a part of coverage range and can perform image processing and identification. Convolutional neural networks generally comprise at least two nonlinear trainable convolutional layers, at least two nonlinear pooling layers and at least one fully-connected layer, i.e. comprising at least five hidden layers, in addition to an input layer and an output layer.
In this embodiment, the standard chinese character training sample is input to the convolutional neural network for training, and after each layer of the convolutional neural network is processed by the standard chinese character training sample (specifically, the response processing of the weight and the offset to the standard chinese character training sample), a corresponding processed output value is obtained at each layer of the convolutional neural network. Because convolutional neural networks contain a large number of layers and the functions of the layers are different, the outputs of the layers are different.
Specifically, if the first layer is a convolutional layer, the output of the convolutional layer can be represented as a l =σ(z l )=σ(a l-1 *W l +b l ) Wherein a is l Represents the output of the l-th layer, z l Representing the output before processing with an activation function, a l-1 Represents the output of the l-1 layer (i.e., the output of the previous layer), σ represents the activation function (the activation function σ used for the convolutional layer is ReLU, which is more effective than other activation functions), and W represents the convolution operation l Represents the weight of the l-th layer, b l Indicating the bias of the l-th layer. If the l-th layer is a pooling layer, the output of the pooling layer may be represented as a l =pool(a l-1 ) Wherein pool refers to a down-sampling calculation, and the down-sampling calculation can select a method of maximum pooling, and the maximum pooling actually is to take the maximum value in n × n samples as a sample value after sampling. In addition to maximum pooling, average pooling is also commonly used, i.e., taking the average of each sample taken over n × n samples as the sampled sample value. If the l-th layer is a full-connection layer, the output of the full-connection layer is calculated in the same way as the output of the traditional deep neural network, and the formula is expressed as a l =σ(z l )=σ(W l a l-1 +b l ) The meaning of the parameters is the same as the above-mentioned explanation, and the description thereof is omitted. In particular, for the output layer L, the activation function σ is a softmax function, and the formula for calculating the output of the output layer L is a L =softmax(z l )=softmax(W L a L-1 +b L ). According to the calculation formula of each layer of the convolutional neural network, the output of each layer of the convolutional neural network can be obtained, and finally the output a of the output layer is obtained L The output is the forward output. Understandably, the forward output obtained in step S111The output condition of the standard Chinese character training sample in the convolutional neural network can be reflected, and the output condition can be compared with objective facts (real results) so as to adjust the convolutional neural network according to errors between the output condition and the objective facts.
S42: constructing an error function according to the forward output and the real result, wherein the expression of the error function is
Where n represents the total number of training samples, x
i Representing the forward output of the i-th training sample, y
i Is represented by the formula
i The corresponding real result of the ith training sample.
The real result is an objective fact, for example, if the input word is a regular script "too", the result of the forward output may be other results such as "big", and the real result is the original input "too", and the real result may be understood as a label value of the training sample for calculating an error with the forward output.
In this embodiment, because the forward output obtained after the convolutional neural network processes the standard chinese character training sample is erroneous with the real result, a corresponding error function may be constructed according to the error, so as to train the convolutional neural network using the error function, and update the weight and the bias, so that the forward output that is the same as or more similar to the real result can be obtained when the updated weight and the bias process the input training sample. Specifically, an appropriate error function may be constructed according to actual conditions, and the error function constructed in this embodiment is
The error between the forward output and the real result can be better reflected.
S43: according to the error function, updating the weight and the bias of the convolutional neural network by adopting a back propagation algorithm based on random gradient descent to obtain a standard Chinese character recognition model, wherein in a full-connection layer of the convolutional neural network, the formula for updating the weight is as follows
In the convolution layer of the convolution neural network, the formula for updating the weight is as follows
W
l ' represents the updated weight, W
l Representing the weight before updating, alpha representing the learning rate, m representing the standard Chinese character training sample, i representing the ith input Chinese character sample, delta
i,l Indicating the sensitivity of the input ith Chinese character sample at the l layer, a
i,l-1 The method comprises the steps of representing the output of an input ith Chinese character sample on the l-1 layer, wherein T represents matrix transposition operation, x represents convolution operation, and rot180 represents operation of turning a matrix by 180 degrees; at the fully-connected layer of the convolutional neural network, the formula for updating the bias is ≥>
At the convolution layer of the convolutional neural network, the formula for updating the bias is
b
l ' denotes an updated bias, b
l Represents the bias before update, alpha represents the learning rate, m represents the canonical Chinese training sample, i represents the ith input Chinese sample, delta
i,l And (u, v) represents the sensitivity of the input ith Chinese character sample in the ith layer, and refers to the position of a small block in each convolution feature map obtained when the convolution operation is carried out.
In this embodiment, after a suitable error function is constructed, a back propagation algorithm based on stochastic gradient descent is used to update network parameters, and the updated convolutional neural network is used as a standard chinese character recognition model. Specifically, in the backward propagation process, because each layer of the convolutional neural network has a large difference, the network parameters should be updated by performing backward propagation according to the actual condition of each layer. In the process of back propagation, firstly, the weight and the bias of the updated output layer are calculated, the error function is adopted to respectively calculate the bias derivative of the weight W and the bias b, a common factor can be obtained,i.e. the sensitivity delta of the output layer
L (L represents an output layer) with the sensitivity δ
L The sensitivity δ of the first layer can be sequentially obtained
l According to delta
l And obtaining the gradient of the l layer in the neural network, and updating the weight and the offset of the convolutional neural network by utilizing the gradient. Specifically, if the current is a fully connected layer, then
Wherein, W
l+1 Represents the weight of l +1 layer, T represents the matrix transposition operation, delta
l+1 Represents the sensitivity of layer l +1, is present>
Representing the operation of multiplication of corresponding elements of two matrices (Hadamard product), sigma representing the activation function, z
l Representing the output before processing with no activation function in the calculation of forward propagation. If the current is a convolutional layer, then
Wherein, denotes convolution operation, rot180 denotes operation of inverting the matrix by 180 degrees, and the meanings of the rest parameters in the formula refer to the content explained by the above parameter meanings, which is not described herein again. If it is currently the pooling level, then->
upsample represents an upsampling operation. Calculating corresponding sensitivity delta according to each layer of the convolutional neural network
l According to the sensitivity delta
l The weights and biases for layer l are updated. The pooling layer has no weight and offset, so the weight and offset of the fully-connected layer and the convolutional layer only need to be updated.
Specifically, in step S43, if the current layer is the full connection layer, the formula for updating the weight is expressed as
Wherein, W
l ' represents the updated weight, W
l Representing the weight before updating, alpha representing the learning rate, m representing the standard Chinese character training sample, i tableIndicating the ith Chinese character sample of the input, delta
i,l Indicating the sensitivity of the input ith Chinese character sample at the l layer, a
i,l-1 Represents the output of the ith Chinese character sample at the l-1 level, T represents the matrix transposition operation, and/or the judgment of the rank of the sample>
I.e. the gradient of the layer l weight W; the formula for updating the bias is expressed as +>
b
l ' denotes an updated bias, b
l Representing the bias before updating alpha represents the learning rate, m represents the standard Chinese character training sample, i represents the ith input Chinese character sample, delta
i,l Indicating the sensitivity of the input ith Chinese character sample at the l layer. If the current is convolution layer, the formula for updating the weight is ^ 4>
The formula for updating the bias is
Wherein, (u, v) refers to the position of a small block (an element constituting the convolution feature map) in each convolution feature map obtained when the convolution operation is performed. And correspondingly updating the weight and the bias of each layer in the convolutional neural network by adopting a back propagation algorithm of random gradient descent to obtain a standard Chinese character recognition model.
Steps S41-S43 can construct an error function from the forward output obtained from the convolutional neural network of the canonical chinese character training sample
And updating the weight and the bias according to the error function in a back-propagation manner, so that a standard Chinese character recognition model can be obtained, deep features of a standard Chinese character training sample are learned by the model, and standard characters can be recognized accurately.
In an embodiment, as shown in fig. 5, in step S60, recognizing a chinese character sample to be tested by using an adjusted chinese handwritten character recognition model, obtaining an error word whose recognition result does not match the real result, and using all the error words as error word training samples, specifically includes the following steps:
s61: and inputting the Chinese character sample to be tested into the adjusted Chinese handwritten character recognition model, and acquiring the output value of each character in the Chinese character sample to be tested in the adjusted Chinese handwritten character recognition model.
In this embodiment, the Chinese handwriting recognition model is adjusted to recognize a Chinese character sample to be tested, where the Chinese character sample to be tested includes a plurality of Chinese characters. In the Chinese character library, the number of commonly used Chinese characters is about three thousand, a probability value of the similarity degree of each character in the Chinese character library and an input Chinese character sample to be tested is set in an output layer for adjusting the Chinese character recognition model, the probability value is an output value of each character in the Chinese character sample to be tested in the Chinese character recognition model, and the probability value can be realized through a softmax function. In short, when inputting the word "me", the output value (expressed by probability) corresponding to each word in the Chinese character library is obtained in adjusting the Chinese character handwriting recognition model, for example, the output value corresponding to "me" in the Chinese character library is 99.5%, and the output values of the rest of the words are added up to 0.5%. By setting the Chinese character sample to be tested, the output value corresponding to each character in the Chinese character library after the Chinese character handwriting character recognition model is adjusted to recognize can obtain a reasonable recognition result according to the output value.
S62: and selecting the maximum output value in the output values corresponding to each character, and acquiring the recognition result of each character according to the maximum output value.
In this embodiment, the maximum output value of all the output values corresponding to each word is selected, and the recognition result of the word can be obtained according to the maximum output value. It can be understood that the output value directly reflects the similarity degree between the input word in the Chinese character sample to be tested and each word in the Chinese character library, and the maximum output value indicates that the word sample to be tested is closest to a certain word in the Chinese character library, and the word corresponding to the maximum output value can be the recognition result of the word, for example, the recognition result output at the end of inputting the word "i" is "i".
S63: and acquiring error words with the recognition result not in accordance with the real result according to the recognition result, and taking all the error words as error word training samples.
In this embodiment, the obtained recognition result is compared with a real result (objective fact), and an error word whose comparison recognition result does not match the real result is used as an error word training sample. It can be understood that the recognition result is only the result of the Chinese character training sample to be tested in the process of adjusting the Chinese handwritten character recognition model, and is possibly different from the real result, which reflects that the model still has defects in recognition accuracy, and the defects can be optimized through the error character training sample to achieve more accurate recognition effect.
S61-S63, according to the output value of each character in the Chinese handwritten character recognition model in the Chinese character sample to be tested, selecting the maximum output value capable of reflecting the similarity degree between the characters from the output values; and obtaining a recognition result through the maximum output value, and obtaining an error word training sample according to the recognition result, thereby providing an important technical premise for further optimizing the recognition accuracy by using the error word training sample.
In the handwriting model training method provided by this embodiment, an optical character recognition technology is used to obtain a pixel value feature matrix of each Chinese character in a Chinese character training sample to be processed, and a standard Chinese character training sample is obtained based on the pixel value feature matrix of each Chinese character in the Chinese character training sample to be processed, and the standard Chinese character training sample can be directly recognized and read by a computer. According to the formula

Initializing weights of convolutional neural network by using smaller values such as interval [ -0.3,0.3]And initializing the bias, wherein the minimum value of the error function can be quickly and effectively found by adopting the initialization mode, and the updating and the adjustment of the convolutional neural network are facilitated. Normalizing the Chinese character training sample to be processed, dividing the two types of values to obtain a binary pixel value characteristic matrix, and dividing the characteristic matrixThe characters corresponding to the matrix are used as standard Chinese character training samples, and the time for training the standard Chinese character recognition model can be obviously shortened. Constructing an error function based on the forward output of the normalized Chinese character training sample obtained by the convolutional neural network>

And the weight and the bias are updated in a back-propagation manner according to the error function, so that a standard Chinese character recognition model can be obtained, deep features of a standard Chinese character training sample are learned by the model, and standard characters can be recognized accurately. And then, the standard Chinese character recognition model is updated in an adjusting way through the non-standard Chinese characters, so that the deep features of the non-standard Chinese characters can be learned through a training and updating way on the premise that the updated adjusted Chinese character recognition model has the capacity of recognizing the standard Chinese characters, and the adjusted Chinese character recognition model can better recognize the non-standard Chinese characters. And then, according to the output value of each character in the Chinese handwritten character recognition model to be tested in the Chinese handwritten character recognition model, selecting a maximum output value capable of reflecting the similarity degree between the characters from the output values, obtaining a recognition result by using the maximum output value, obtaining an error character training sample according to the recognition result, inputting all error characters serving as error character training samples into the Chinese handwritten character recognition model to be adjusted for training and updating, and obtaining a target Chinese handwritten character recognition model. By adopting the error word training sample, the adverse effects caused by excessive learning and excessive weakening generated in the original training process can be eliminated to a great extent, and the recognition accuracy can be further optimized. In addition, in the handwriting model training method provided by the embodiment, a backward propagation algorithm based on random gradient is adopted during training for standardizing the Chinese character recognition model and adjusting the Chinese character handwriting recognition model, so that the training efficiency and the training effect are still better under the condition of a large number of training samples. The target Chinese handwritten character recognition model adopts a back propagation algorithm based on batch gradient descent during training, can ensure the full update of parameters in the model, carries out back propagation update on errors generated by a training sample in the training process, and comprehensively carries out back propagation update according to the generated errorsAnd updating the parameters and improving the identification accuracy of the obtained model.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 6 is a schematic block diagram of a handwriting model training apparatus corresponding to the handwriting model training method in one-to-one embodiment. As shown in fig. 6, the handwriting model training apparatus includes a pixel value feature matrix obtaining module 10, a normative chinese character training sample obtaining module 20, an initialization module 30, a normative chinese character recognition model obtaining module 40, an adjusted chinese character handwriting recognition model obtaining module 50, an error character training sample obtaining module 60, and a target chinese character recognition model obtaining module 70. The implementation functions of the pixel value feature matrix obtaining module 10, the normative Chinese character training sample obtaining module 20, the initialization module 30, the normative Chinese character recognition model obtaining module 40, the adjusted Chinese handwritten character recognition model obtaining module 50, the error character training sample obtaining module 60, and the target Chinese handwritten character recognition model obtaining module 70 correspond to the steps corresponding to the handwriting model training method in the embodiment one to one, and for avoiding redundancy, detailed description is not needed in this embodiment.
The pixel value feature matrix obtaining module 10 is configured to obtain a pixel value feature matrix of each chinese character in a chinese character training sample to be processed by using an optical character recognition technology.
And a standard Chinese character training sample obtaining module 20, configured to obtain a standard Chinese character training sample based on a pixel value feature matrix of each Chinese character in the Chinese character training sample to be processed.
And an initialization module 30 for initializing the convolutional neural network.
And the standard Chinese character recognition model acquisition module 40 is used for inputting the standard Chinese character training samples into the convolutional neural network for training, updating the weight and the bias of the convolutional neural network by adopting a back propagation algorithm based on random gradient descent, and acquiring a standard Chinese character recognition model.
And the adjusted Chinese handwriting recognition model obtaining module 50 is used for obtaining the non-standard Chinese character training sample, inputting the non-standard Chinese character training sample into the standard Chinese character recognition model for training, updating the weight and the bias of the standard Chinese character recognition model by adopting a backward propagation algorithm based on random gradient descent, and obtaining the adjusted Chinese handwriting recognition model.
The error word training sample obtaining module 60 is configured to obtain a Chinese word sample to be tested, identify the Chinese word sample to be tested by using the adjusted Chinese handwriting recognition model, obtain error words with a recognition result not matching the real result, and use all the error words as error word training samples.
And a target Chinese handwritten character recognition model obtaining module 70, configured to input the error character training sample into the adjusted Chinese handwritten character recognition model for training, update the weight and bias of the adjusted Chinese handwritten character recognition model by using a batch gradient descent-based back propagation algorithm, and obtain the target Chinese handwritten character recognition model.
Preferably, the canonical chinese training sample acquisition module 20 includes a normalized pixel value feature matrix acquisition unit 21 and a canonical chinese training sample acquisition unit 22.
A normalized pixel value feature matrix obtaining unit 21, configured to obtain a pixel value feature matrix of each Chinese character in a Chinese character training sample to be processed, and perform normalization processing on each pixel value in the pixel value feature matrix to obtain a normalized pixel value feature matrix of each Chinese character, where a formula of the normalization processing is
MaxValue is the maximum value of the pixel values in the pixel value characteristic matrix of each Chinese character, minValue is the minimum value of the pixel values in the pixel value characteristic matrix of each Chinese character, x is the pixel value before normalization, and y is the pixel value after normalization.
The normalized Chinese character training sample obtaining unit 22 is configured to divide the pixel values in the normalized pixel value feature matrix of each Chinese character into two types of pixel values, establish a binarized pixel value feature matrix of each Chinese character based on the two types of pixel values, and combine the binarized pixel value feature matrices of each Chinese character as the normalized Chinese character training sample.
Preferably, the initialization module 30 is configured to initialize the convolutional neural network, wherein the initialized weights of the convolutional neural network satisfy the formula
n
l Represents the number of training samples input at the l-th layer, S () represents a variance operation, W
l Represents the weight of the l-th layer, is>
Denoted arbitrary, l denotes the l-th layer in a convolutional neural network.
Preferably, the canonical chinese character recognition model acquisition module 40 includes a forward output acquisition unit 41, an error function construction unit 42, and a canonical chinese character recognition model acquisition unit 43.
A forward output obtaining unit 41, configured to input the standard chinese character training sample into the convolutional neural network, and obtain a forward output of the standard chinese character training sample in the convolutional neural network.
An error function construction unit 42 for constructing an error function based on the forward output and the real result, the expression of the error function being
Where n represents the total number of training samples, x
i Represents the forward output of the i-th training sample, y
i Is represented by the formula
i The corresponding real result of the ith training sample.
A normalized Chinese character recognition model obtaining unit 43, configured to obtain a normalized Chinese character recognition model by updating the weight and the bias of the convolutional neural network according to the error function by using a back propagation algorithm based on stochastic gradient descent, where in a full connection layer of the convolutional neural network, a formula for updating the weight is
Convolution in a convolutional neural networkLayer, update formula of weight is->
W
l ' represents the updated weight, W
l Representing the weight before updating, alpha representing the learning rate, m representing the standard Chinese character training sample, i representing the ith input Chinese character sample, delta
i,l Indicating the sensitivity of the input ith Chinese character sample at the l layer, a
i,l-1 The method comprises the steps of representing the output of an input ith Chinese character sample on the l-1 layer, wherein T represents matrix transposition operation, x represents convolution operation, and rot180 represents operation of turning a matrix by 180 degrees; at the fully-connected layer of the convolutional neural network, the formula for updating the bias is ≥>
At the convolutional layer of the convolutional neural network, the formula for updating the bias is ≥>
b
l ' denotes an updated bias, b
l Represents the bias before update, alpha represents the learning rate, m represents the canonical Chinese training sample, i represents the ith input Chinese sample, delta
i,l And (u, v) represents the sensitivity of the input ith Chinese character sample in the ith layer, and refers to the position of a small block in each convolution feature map obtained when the convolution operation is carried out.
Preferably, the error word training sample acquisition module 60 includes a model output value acquisition unit 61, a model recognition result acquisition unit 62, and an error word training sample acquisition unit 63.
The model output value obtaining unit 61 is configured to input the Chinese character sample to be tested to the adjusted Chinese handwritten character recognition model, and obtain an output value of each character in the Chinese character sample to be tested in the adjusted Chinese handwritten character recognition model.
The model identification result obtaining unit 62 is configured to select a maximum output value of the output values corresponding to each word, and obtain an identification result of each word according to the maximum output value.
And an error word training sample obtaining unit 63, configured to obtain, according to the recognition result, error words whose recognition result does not match the real result, and use all the error words as error word training samples.
Fig. 7 shows a flowchart of the handwritten word recognition method in the present embodiment. The handwritten character recognition method can be applied to computer equipment configured by organizations such as banks, investments, insurance and the like, and is used for recognizing handwritten Chinese characters to achieve the purpose of artificial intelligence. As shown in fig. 7, the handwritten word recognition method includes the steps of:
s80: acquiring a Chinese character to be recognized, recognizing the Chinese character to be recognized by adopting a target Chinese handwritten character recognition model, and acquiring an output value of the Chinese character to be recognized in the target Chinese handwritten character recognition model, wherein the target Chinese handwritten character recognition model is acquired by adopting the handwriting model training method.
Wherein, the Chinese character to be recognized refers to the Chinese character to be recognized.
In this embodiment, a Chinese character to be recognized is obtained, the Chinese character to be recognized is input into the target Chinese handwritten character recognition model for recognition, an output value of the Chinese character to be recognized in the target Chinese handwritten character recognition model is obtained, one Chinese character to be recognized corresponds to more than three thousand output values (the specific number is based on the Chinese character library), and a recognition result of the Chinese character to be recognized can be determined based on the output value. Specifically, the Chinese character to be recognized is represented by a binary pixel value feature matrix which can be directly recognized by a computer.
S90: and acquiring a target probability output value according to the output value and a preset Chinese semantic word library, and acquiring a recognition result of the Chinese character to be recognized based on the target probability output value.
The preset Chinese semantic word library is a preset word library which describes semantic relations among Chinese words based on word frequency. For example, in the chinese semantic word library, for words of two words such as "yang X", the probability of occurrence of "sun" is 30.5%, the probability of occurrence of "yang" is 0.5%, and the sum of the probabilities of occurrence of the remaining words of two words such as "yang X", such as "sun pride" is 69%. The target probability output value is a probability value for acquiring a recognition result of the Chinese character to be recognized by combining the output value and a preset Chinese semantic word library.
Specifically, the step of obtaining the target probability output value by using the output value and a preset Chinese semantic word library comprises the following steps: (1) And selecting the maximum value in the output values corresponding to each character in the Chinese characters to be recognized as a first probability value, and acquiring the primary recognition result of the Chinese characters to be recognized according to the first probability value. (2) And acquiring the left semantic probability value and the right semantic probability value of the word to be identified according to the initial identification result and the Chinese semantic word library. It is understood that for a text, the words in the text are sequential, such as "red X positive", and for the "X" word, there are probability values corresponding to the words "red X" and "X positive" in the left-to-right directions, i.e., left semantic probability value and right semantic probability value. (3) And respectively setting a weight of an output value corresponding to each word in the Chinese characters to be recognized, a weight of a left semantic probability value and a weight of a right semantic probability value. Specifically, a weight of 0.4 may be assigned to an output value corresponding to each word in the Chinese character to be recognized, a weight of 0.3 may be assigned to the left semantic probability value, and a weight of 0.3 may be assigned to the right semantic probability value. (4) And multiplying the set weights by the corresponding probability values respectively to obtain the probability values after the weighted operation, adding the probability values after the weighted operation to obtain target probability output values (the target probability output values are multiple, and the specific number can be based on a Chinese character library), and selecting a character corresponding to the maximum value in the target probability output values as the recognition result of the Chinese character to be recognized. In fact, the first 5 probability values with the largest value in the output values can be selected first, the first 5 probability values represent the most possible 5 characters (recognition results), and only the 5 characters are combined with the Chinese semantic word library to calculate the target probability output value, so that only 5 target probability output values are obtained, and the recognition efficiency can be greatly improved. By combining the output value with a preset Chinese semantic word library, an accurate recognition result can be obtained. It can be understood that for the recognition of a single word (non-text), the corresponding recognition result can be directly obtained according to the maximum value in the output values, and the recognition based on Chinese semantics is not required to be added.
And S80-S90, recognizing the Chinese character to be recognized by adopting a target Chinese handwritten character recognition model, and acquiring a recognition result of the Chinese character to be recognized by combining the output value and a preset Chinese semantic word library. The target Chinese handwritten character recognition model has high recognition accuracy, and the recognition accuracy of Chinese handwriting is further improved by combining the Chinese semantic word library.
In the handwritten character recognition method provided by the embodiment of the invention, the Chinese character to be recognized is input into the target Chinese handwritten character recognition model for recognition, and a recognition result is obtained by combining a preset Chinese semantic word library. When the target Chinese handwritten character recognition model is adopted to recognize the Chinese handwritten character, an accurate recognition result can be obtained.
Fig. 8 shows a functional block diagram of a handwritten word recognition arrangement in one-to-one correspondence with the handwritten word recognition method in an embodiment. As shown in fig. 8, the handwritten word recognition apparatus includes an output value acquisition module 80 and a recognition result acquisition module 90. The implementation functions of the output value obtaining module 80 and the recognition result obtaining module 90 correspond to the steps corresponding to the handwritten character recognition method in the embodiment one by one, and for avoiding repeated descriptions, detailed descriptions are not provided in this embodiment.
The handwritten character recognition device comprises an output value acquisition module 80, which is used for acquiring Chinese characters to be recognized, recognizing the Chinese characters to be recognized by adopting a target Chinese handwritten character recognition model and acquiring the output values of the Chinese characters to be recognized in the target Chinese handwritten character recognition model; the target Chinese handwritten character recognition model is obtained by adopting a handwriting model training method.
And the recognition result acquisition module 90 is configured to acquire a target probability output value according to the output value and a preset chinese semantic word library, and acquire a recognition result of the chinese character to be recognized based on the target probability output value.
The present embodiment provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the handwriting model training method in the embodiments is implemented, and for avoiding repetition, details are not repeated here. Alternatively, the computer program, when executed by the processor, implements the functions of each module/unit of the handwriting model training apparatus in the embodiments, and is not described herein again to avoid redundancy. Alternatively, the computer program is executed by the processor to implement the functions of the steps in the handwritten character recognition method in the embodiments, and is not repeated herein to avoid repetition. Alternatively, the computer program is executed by the processor to implement the functions of the modules/units in the handwritten character recognition apparatus in the embodiments, which are not described herein again to avoid repetition.
Fig. 9 is a schematic diagram of a computer device provided by an embodiment of the invention. As shown in fig. 9, the computer apparatus 100 of this embodiment includes: the handwriting training method includes a processor 101, a memory 102, and a computer program 103 stored in the memory 102 and capable of running on the processor 101, where the computer program 103 implements the handwriting training method in the embodiment when executed by the processor 101, and details are not repeated herein to avoid repetition. Alternatively, the computer program is executed by the processor 101 to implement the functions of each model/unit in the handwriting model training apparatus in the embodiment, which are not described herein again to avoid repetition. Alternatively, the computer program is executed by the processor 101 to implement the functions of the steps in the handwritten character recognition method in the embodiment, and is not repeated here to avoid repetition. Alternatively, the computer program realizes the functions of the modules/units in the handwritten word recognition apparatus in the embodiments when executed by the processor 101. To avoid repetition, it is not repeated herein.
The computing device 100 may be a desktop computer, a notebook, a palm top computer, a cloud server, or other computing devices. The computer device may include, but is not limited to, a processor 101, a memory 102. Those skilled in the art will appreciate that fig. 9 is merely an example of a computing device 100 and is not intended to limit the computing device 100 and that it may include more or less components than those shown, or some of the components may be combined, or different components, e.g., the computing device may also include input output devices, network access devices, buses, etc.
The Processor 101 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The storage 102 may be an internal storage unit of the computer device 100, such as a hard disk or a memory of the computer device 100. The memory 102 may also be an external storage device of the computer device 100, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), etc., provided on the computer device 100. Further, the memory 102 may also include both internal storage units and external storage devices of the computer device 100. The memory 102 is used for storing computer programs and other programs and data required by the computer device. The memory 102 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not depart from the spirit and scope of the embodiments of the present invention, and they should be construed as being included therein.