Method and device for training convolutional neural network, method and device for article classification
Through convolutional neural network training and feature extraction, the problem of document classification in the existing technology that cannot identify subject information not in the text is solved, the accuracy of document classification and user retrieval efficiency are improved, and the accuracy of formula features is ensured.
Patent Information
- Application Number
- CN202010388933.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-05-09
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-05-09
AI Technical Summary
It is difficult for the existing technology to identify documents whose subject information is not in the text in document subject classification, resulting in low efficiency for users to retrieve target information, or even failure to retrieve the target information.
Using the convolutional neural network training method, by obtaining the sample article set, extracting formulas as positive samples and negative samples, using the marginal loss function to adjust the weight of neuron nodes, training the convolutional neural network to improve the accuracy of formula feature extraction, and will be used to The formula features of the processed articles and the standard article features are similar to each other for classification.
It improves the accuracy of document classification and user retrieval efficiency, ensures high correlation between similar formulas, and ensures the accuracy of information extraction from all formulas in the article to be processed.
Smart Images

Figure CN113626588B
Abstract
Description
Technical Field
[0001] The present application relates to the field of text processing, and in particular to a method and apparatus for training a convolutional neural network, a method and apparatus for article classification, a computing device, and a computer-readable storage medium. Background Art
[0002] With the rapid development of Internet technology, all kinds of data used by people are growing at an explosive rate. A large amount of data is stored in the database. Through the means of data classification and analysis, valuable information in a large amount of data can be effectively utilized. Data classification and analysis can be applied to market research, data analysis, pattern recognition, image processing, artificial intelligence, document classification and other fields.
[0003] At present, in the subject classification of documents, the subject distribution of the documents is generally calculated based on the statistical characteristics of the words in the documents. However, this method can only perform subject identification on the text containing subject information in the document, and cannot identify the subject of the document if the subject information is not in the text of the document. Therefore, it is difficult to effectively classify documents where the subject information is not in the text, which will greatly affect the efficiency of users in retrieving target information and may even cause users to be unable to retrieve target information. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a method and apparatus for training a convolutional neural network and classifying articles, a computing device, and a computer-readable storage medium to address the technical defects existing in the prior art.
[0005] The present application embodiment discloses a method for training a convolutional neural network, including:
[0006] Obtain a sample article set, and collect the formula of each sample article in the sample article set to obtain a formula set;
[0007] A single formula in the formula set is taken as a positive sample, other single formulas in the sample article where the single formula is located are taken as positive examples, and formulas in other sample articles are taken as negative examples. The positive samples, positive examples and negative examples are input into a convolutional neural network for training until the training stop condition is reached.
[0008] Optionally, inputting the positive samples, positive examples and negative examples into a convolutional neural network for training until a training stop condition is reached includes:
[0009] The positive sample, positive example and negative example are input into a convolutional neural network to obtain positive sample features, positive example features and negative example features respectively;
[0010] The distance between the positive sample feature and the positive example feature and the distance between the positive sample feature and the negative example feature are calculated respectively, and the difference between the two distances is calculated by using a marginal loss function;
[0011] According to the difference, the weight value of each layer of neuron nodes is adjusted in turn from the fully connected layer to the input layer of the convolutional neural network, the current training is completed, and the next training is continued until the training stop condition is reached.
[0012] Optionally, the training stop condition includes: the difference change rate is less than a preset stability threshold.
[0013] Optionally, before the positive samples, positive examples and negative examples are input into the convolutional neural network for training, the method further includes:
[0014] Extracting keywords from the sample article where the single formula is located, and using the keywords as labels corresponding to the single formula;
[0015] Taking the single formula as a positive sample and the formulas in other sample articles as negative samples, the positive sample, the label corresponding to the positive sample, the negative sample and the label corresponding to the negative sample are input into a convolutional neural network to obtain positive sample features and negative sample features;
[0016] A loss value is calculated based on the positive sample features and the labels corresponding to the positive samples and the negative sample features and the labels corresponding to the negative samples, and the parameters of the convolutional neural network are adjusted according to the loss value until the pre-training stop condition is reached.
[0017] The present application embodiment discloses a method for article classification, including:
[0018] Receiving an article to be processed, and obtaining a formula in the article to be processed;
[0019] Inputting the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the above-mentioned convolutional neural network training method;
[0020] The articles to be processed are classified according to formula features corresponding to the articles to be processed.
[0021] Optionally, the convolutional neural network includes an input layer, an intermediate layer and a fully connected layer;
[0022] Inputting the formula in the article to be processed into the convolutional neural network, and obtaining the formula features corresponding to the article to be processed output by the convolutional neural network, including:
[0023] The formula in the article to be processed is input to the middle layer through the input layer of the convolutional neural network, and the middle layer processes the formula to obtain high-dimensional features; the high-dimensional features are input to the fully connected layer of the convolutional neural network for normalization to obtain formula features.
[0024] Optionally, the articles to be processed are classified according to the formula features in the articles to be processed, including:
[0025] Get standard articles belonging to preset categories;
[0026] Collecting formulas from the standard article;
[0027] According to the formula in the standard article, obtaining the formula feature corresponding to the standard article;
[0028] Calculating the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article;
[0029] The articles to be processed whose similarity exceeds a preset similarity threshold are classified into preset categories.
[0030] Optionally, the articles to be processed are classified according to the formula features in the articles to be processed, including:
[0031] Obtaining the grouped texts in each group, and collecting the formulas in the grouped texts;
[0032] According to the formula in the grouped text, obtaining the formula feature corresponding to the grouped text;
[0033] Calculating the original distance between the formula feature corresponding to the article to be processed and the formula feature corresponding to each of the grouped texts one by one;
[0034] Acquire the grouped texts whose original distance is less than the preset distance as screening texts, and determine the number of screening texts whose original distance is less than the preset distance in each group;
[0035] The articles to be processed are divided into the group containing the largest number of filtered texts.
[0036] The present application embodiment discloses a convolutional neural network training device, including:
[0037] A collection module is configured to obtain a sample article set, collect the formula of each sample article in the sample article set to obtain a formula set;
[0038] The training module is configured to take a single formula in the formula set as a positive sample, take other single formulas in the sample article where the single formula is located as positive examples, take formulas in other sample articles as negative examples, and input the positive samples, positive examples and negative examples into the convolutional neural network until the training stop condition is reached.
[0039] The present application also discloses a device for classifying articles, including:
[0040] A receiving module is configured to receive an article to be processed and obtain a formula in the article to be processed;
[0041] An acquisition module is configured to input the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the above-mentioned convolutional neural network training method;
[0042] The classification module is configured to classify the articles to be processed according to the formula features corresponding to the articles to be processed.
[0043] An embodiment of the present application discloses a computing device, including a memory, a processor, and computer instructions stored in the memory and executable on the processor. When the processor executes the instructions, the steps of the method for training a convolutional neural network or the method for classifying an article as described above are implemented.
[0044] An embodiment of the present application discloses a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the method for training a convolutional neural network or the method for classifying articles as described above.
[0045] The present application provides a method and device for training a convolutional neural network, and a method and device for classifying articles. The above-mentioned convolutional neural network training method trains the convolutional neural network to achieve the training purpose of making positive examples more similar to positive samples and negative examples dissimilar to positive samples, that is, to make any two formulas in the same sample article have a high correlation. During the use of the trained convolutional neural network, the trained convolutional neural network is used to extract the features of the formulas in the article to be processed, so that the correlation between similar formulas is high, thereby ensuring the accuracy of the information extracted from all formulas in the article to be processed. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 is a schematic diagram of the structure of a computing device according to an embodiment of the present application;
[0047] Figure 2 It is a flowchart of the method for training a convolutional neural network in the first embodiment of the present application;
[0048] Figure 3 It is a flowchart of a method for training a convolutional neural network according to the second embodiment of the present application;
[0049] Figure 4 It is a schematic diagram of the structure of the convolutional neural network of this application;
[0050] Figure 5 is a flowchart of a method for classifying articles in the third embodiment of the present application;
[0051] Figure 6 It is a schematic diagram of the process of classifying the articles to be processed in this application;
[0052] Figure 7a and Figure 7b It is a schematic diagram of clustering the articles to be processed in this application;
[0053] Figure 8 Schematic diagram of the structure of a device for training a convolutional neural network according to the fourth embodiment of the present application;
[0054] Fig. 9 It is a schematic diagram of the device structure for classifying articles in the fifth embodiment of the present application. DETAILED DESCRIPTION
[0055] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0056] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.
[0057] It should be understood that although the terms first, second, etc. may be used to describe various information in one or more embodiments of this specification, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0058] First, the terms involved in one or more embodiments of the present invention are explained.
[0059] Articles to be processed: The articles to be processed are articles in the data set that have not been classified. In other words, the articles to be processed are articles that need to be classified, including text, formulas, tables, etc.
[0060] Formula features: Extract formula features through convolutional neural networks.
[0061] Convolutional Neural Network (CNN): It is a feedforward neural network. A feedforward neural network is one in which neurons are arranged in layers, and each neuron is only connected to the neurons in the previous layer. Convolutional neural networks can be used to extract image features.
[0062] Convolutional layer: uses a sampler to collect key data content from the input data.
[0063] Max pool layer: It compresses the results of the convolutional layer to obtain more important features, while also effectively controlling overfitting.
[0064] Flatten layer: used to "flatten" the input, that is, to convert multi-dimensional input into one dimension.
[0065] Fully connected layer: Integrates the highly abstract features after multiple convolutions, and then normalizes the formula features corresponding to the final output formula.
[0066] Word embedding technology: It is a general term for a set of language modeling and feature learning technologies in natural language processing, that is, mapping words or phrases in the vocabulary to a continuous vector space with lower dimensions.
[0067] Clustering: In a given data set, clustering algorithms are used to divide it into different groups. In theory, data in the same group have the same attributes or features, while data in different groups have different attributes or features.
[0068] Cosine similarity: The similarity is evaluated by calculating the cosine value of the angle between two vectors.
[0069] Sample Article Collection: A collection of a large number of sample articles.
[0070] Sample article: Article on training convolutional neural networks.
[0071] Pre-training: Perform preliminary training on the convolutional neural network to enable the convolutional neural network to obtain better initial values.
[0072] Mean-shift clustering algorithm: It is a centroid-based algorithm, that is, its goal is to locate the center point of each group or class by updating the center point candidate, and updating the center point candidate to the mean of the points in the sliding window. These candidate sliding windows will then be filtered in the post-processing stage to reduce adjacent duplicate points, and finally form a set of center points and their corresponding groups.
[0073] Loss function: A function that maps the value of a random event or its related random variables into a non-negative real number to represent the "risk" or "loss" of the random event.
[0074] Cross Entropy Loss: It is a way to measure the difference between the predicted value and the actual value of the convolutional neural network. The purpose of the loss function is to learn how to directly predict the label. Compared with the quadratic cost function, it can more effectively promote the training of convolutional neural networks.
[0075] Margin loss: is a ternary loss function that uses margins to measure the embedding representation distance between samples, with the aim of predicting the relative distance between input samples.
[0076] In the present application, a method and apparatus for training a convolutional neural network, a method and apparatus for article classification, a computing device, and a computer-readable storage medium are provided, which are described in detail one by one in the following embodiments.
[0077] Figure 1 1 is a block diagram showing a structure of a computing device 100 according to an embodiment of the present specification. The components of the computing device 100 include but are not limited to a memory 110 and a processor 120. The processor 120 is connected to the memory 110 via a bus 130, and a database 150 is used to store data.
[0078] The computing device 100 also includes an access device 140 that enables the computing device 100 to communicate via one or more networks 160. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 140 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0079] In one embodiment of the present specification, the above components of the computing device 100 and Figure 1 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 1 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0080] The computing device 100 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 100 may also be a mobile or stationary server.
[0081] The processor 120 may execute Figure 2 Steps in the method shown. Figure 2 is a schematic flowchart showing a method for training a convolutional neural network according to the first embodiment of the present application, including steps 202 to 204.
[0082] Step 202: Obtain a sample article set, and collect formulas in the sample article set to obtain a formula set.
[0083] The sample article collection includes a large number of sample article collections, and the sample articles may be articles in documents, papers, journals or magazines.
[0084] The formula can be in text format or in picture format. For the formula in text format, the purpose of training the convolutional neural network in this embodiment is to enable the convolutional neural network to have the ability to recognize the formula text; for the formula in picture format, the purpose of training the convolutional neural network in this embodiment is to enable the convolutional neural network to have the ability to recognize the formula picture.
[0085] Step 204: taking a single formula in the formula set as a positive sample, taking other single formulas in the sample article where the single formula is located as positive examples, taking formulas in other sample articles as negative examples, and inputting the positive samples, positive examples and negative examples into a convolutional neural network for training until the training stop condition is reached.
[0086] Specifically, step 204 includes the following steps S2042 to S2046:
[0087] S2042. Input the positive sample, positive example and negative example into a convolutional neural network to obtain positive sample features, positive example features and negative example features, respectively.
[0088] S2044. Calculate the distance between the positive sample feature and the positive example feature and the distance between the positive sample feature and the negative example feature respectively, and calculate the difference between the two distances by using a marginal loss function.
[0089] The loss function used for convolutional neural network training in this step is a marginal loss function. The features output by the fully connected layer in the convolutional neural network structure are calculated using the marginal loss. The difference between the distance between the positive sample feature and the positive example feature and the distance between the positive sample feature and the negative example feature is calculated using the marginal loss function.
[0090] S2046. According to the difference, the weight values of the neuron nodes in each layer are adjusted in sequence from the fully connected layer to the input layer of the convolutional neural network, the current training is completed, and the next training is continued until the training stop condition is reached.
[0091] Specifically, the training stop condition includes: the change rate of the difference is less than a preset stability threshold.
[0092] In addition, the input positive sample, positive example, and negative example are a triplet sampled from the training set. This triplet consists of a positive sample, a positive example, and a negative example. The purpose of convolutional neural network training is to make the difference between the distance between positive samples and positive examples and the distance between positive samples and negative examples greater than a threshold. In short, it is to make positive samples more similar to positive examples and dissimilar to negative examples.
[0093] The generation of training data is described in detail below. Assume that there are 10,000 formulas in the formula set and training data needs to be generated one by one.
[0094] In the first training data, the positive sample is the first formula; the positive example is another formula extracted from the sample article where the first formula is located; the negative example is a formula in the sample article other than the sample article where the first formula is located in the formula set.
[0095] In the second training data, the positive sample is the second formula; the positive example is another formula extracted from the sample article where the second formula is located; the negative example is a formula in the sample articles other than the sample article where the second formula is located in the formula set, and so on, to complete the generation of all training data.
[0096] In this embodiment, the convolutional neural network is trained to achieve the training purpose of making positive examples more similar to positive samples and negative examples dissimilar to positive samples, that is, to make any two formulas in the same sample article have a high correlation. During the use of the trained convolutional neural network, the trained convolutional neural network is used to extract the features of the formulas in the article to be processed, so that the correlation between similar formulas is high, thereby ensuring the accuracy of the information extracted from all formulas in the article to be processed.
[0097] Figure 3 3 is a schematic flowchart showing a method for training a convolutional neural network according to a second embodiment of the present application, including steps 302 to 310.
[0098] Step 302: Obtain a sample article set, and collect formulas in the sample article set to obtain a formula set.
[0099] The sample article collection includes a large number of sample article collections, and the sample articles may be texts in documents, papers, journals or magazines.
[0100] The formula can be in text format or in picture format. For the formula in text format, the purpose of training the convolutional neural network in this embodiment is to enable the convolutional neural network to have the ability to recognize the formula text; for the formula in picture format, the purpose of training the convolutional neural network in this embodiment is to enable the convolutional neural network to have the ability to recognize the formula picture.
[0101] The following steps 304 to 306 are used to pre-train the convolutional neural network.
[0102] Step 304: extract keywords from the abstract of the sample article where the single formula is located, and use the keywords as labels corresponding to the single formula.
[0103] Since there is no data set for formula similarity, keywords extracted from the abstracts of sample articles are used as labels for formulas. The formulas in the sample articles have a high correlation with the keywords. The pre-training in the following steps enables semantic connection between the formulas and the keywords, ensuring that the convolutional neural network trained in step 310 can converge quickly.
[0104] The negative sampling technology used in this embodiment generates negative samples with a probability of 0.5. Here, the labels of negative samples are randomly sampled labels, and the labels of positive samples are keywords in the abstract of the sample article where the formula is located. The single formula is the positive sample, and the labels of the formulas in the negative samples are randomly extracted keywords, which are converted into a binary classification task for pre-training of the convolutional neural network.
[0105] Specifically, the generation of pre-training data is described below.
[0106] Generate a random number between 0 and 1. If the random number is greater than 0.5, the data is a positive sample. If the random number is less than 0.5, the data is a negative sample.
[0107] Assume that the random number of the first formula is greater than 0.5, so it is a positive sample, and extract keywords from the abstract of the sample article where the first formula is located as labels.
[0108] Assuming that the random number of the second formula is less than 0.5, the second formula is a negative sample, and keywords are extracted from other sample articles as labels, and so on, to complete the generation of pre-training data.
[0109] The pre-training data generated above has a balanced amount of positive samples and negative samples, ensuring that the convolutional neural network pre-training can obtain a good initial value and improving the training effect of the convolutional neural network in the following steps.
[0110] Step 306: Take the single formula as a positive sample, take the formulas in other sample articles as negative samples, input the positive sample, the label corresponding to the positive sample, the negative sample and the label corresponding to the negative sample into a convolutional neural network to obtain positive sample features and negative sample features.
[0111] The single formula is used as a positive sample, the abstract keyword corresponding to the formula is used as the label corresponding to the positive sample, the formulas in other sample articles are used as negative samples, and the randomly selected abstract keywords are used as the labels corresponding to the negative samples and input into the convolutional neural network for pre-training. Through pre-training, the convolutional neural network obtains a better initial value, ensuring that the convolutional neural network trained in the following steps can converge quickly.
[0112] Step 308: Calculate a loss value based on the positive sample features and the labels corresponding to the positive samples and the negative sample features and the labels corresponding to the negative samples, and adjust the parameters of the convolutional neural network according to the loss value until the pre-training stop condition is reached.
[0113] Combine the following Figure 4 The structure of the convolutional neural network shown specifically illustrates the pre-training process of this step. Figure 4 In the example, the formula is shown in the formula picture as an example for schematic explanation.
[0114] The convolutional neural network includes an input layer, an intermediate layer and a fully connected layer. The intermediate layer is the first convolution layer, the second maximum pooling layer, the third convolution layer, the fourth maximum pooling layer, the fifth convolution layer, the sixth maximum pooling layer and the seventh flattening layer connected in sequence. Assume that the formula in the formula picture of the sample article is The extraction of formula image features goes through the following steps in sequence.
[0115] 1) The input image size of the first convolutional layer is 32x333x1 (height x width x number of color channels).
[0116] 2) The convolution kernel size of the first convolution layer (Conv) is 3x3, the number of convolution kernels c is 32, the step length s of each movement during calculation is 1, and the result of convolution calculation of the formula image by 32 convolution kernels of size 3x3 is input to the second maximum pooling layer.
[0117] 3) The size s of the second maximum pooling layer (Max pool) is 2x4. The second maximum pooling layer compresses the results of the first convolutional layer to obtain more important features, and inputs the compressed features into the third convolutional layer.
[0118] 4) The convolution kernel size of the third convolution layer is 5x5, and the number of convolution kernels c is 32. The step length s of each movement during calculation is 1, and the features output by the second maximum pooling layer are convolved with 32 convolution kernels of size 5x5, and the result is input to the fourth maximum pooling layer.
[0119] 5) The size s of the fourth maximum pooling layer is 2x4. The fourth maximum pooling layer compresses the results of the third convolutional layer to obtain more important features, and inputs the compressed features into the fifth convolutional layer.
[0120] 6) The convolution kernel size of the fifth convolution layer is 3x3, the number of convolution kernels c is 32, and the step size s of each movement during calculation is 1. The features output by the fourth maximum pooling layer are convolved with 32 convolution kernels of size 3x3, and the result is input into the sixth maximum pooling layer.
[0121] 7) The size s of the sixth maximum pooling layer is 3x3, and the step size s is 3. The sixth maximum pooling layer compresses the result of the fifth convolutional layer and outputs 1x5x32-dimensional features.
[0122] 8) The seventh flattening layer (Flatten) converts the 1x5x32 dimension output of the sixth maximum pooling layer into a one-dimensional feature to obtain a 1x160 dimensional feature.
[0123] 9) Fully connected layer (Fc): Integrate the highly abstract features after multiple convolutions, and then normalize them to output the formula features corresponding to the formula image as 1x64-dimensional features.
[0124] The loss function used for convolutional neural network pre-training is the cross entropy loss function, which is a way to measure the deviation between the predicted value and the actual value of the convolutional neural network. The features output by the fully connected layer in the convolutional neural network are calculated by dot product with the label vector, and the error between the predicted value and the actual value is obtained through the cross entropy loss function. The gradient of the loss function is calculated and passed back to the parameters of the previous layer of the neural network to correct the model, thus completing the pre-training of the convolutional neural network.
[0125] Step 310: Take a single formula in the formula set as a positive sample, take other single formulas in the sample article where the single formula is located as positive examples, take formulas in other sample articles as negative examples, and input the positive samples, positive examples and negative examples into a convolutional neural network for training until the training stop condition is reached.
[0126] This embodiment pre-trains the convolutional neural network to ensure that the convolutional neural network pre-training can obtain a good initial value. In this way, during the training process, the positive samples, positive examples and negative examples are input into the convolutional neural network for training to achieve the training purpose of making the positive example more similar to the positive sample and the negative example dissimilar to the positive sample, that is, to make any two formulas in the same sample article have a high correlation. In the process of using the trained convolutional neural network, the trained convolutional neural network is used to extract the features of the formulas in the article to be processed, so that the correlation between similar formulas is high, thereby ensuring the accuracy of the information extracted from all formulas in the article to be processed.
[0127] Figure 5 A method for article classification provided in the third embodiment of the present application is shown, including steps 502 to 506.
[0128] Step 502: Receive an article to be processed, and obtain a formula in the article to be processed.
[0129] The article to be processed is an article in a document, paper, journal or magazine, and the article to be processed is an article that has not been classified yet.
[0130] The language of the article to be processed can be Chinese, English, Korean, Japanese, etc. The source of the article to be processed can be a library or an article specified by a user, and this application does not limit this. The article to be processed generally includes characters, tables, pictures and formulas. The article to be processed includes at least one formula, and this application does not limit the number of formulas in the article to be processed.
[0131] Specifically, by collecting the formulas in the article to be processed, the formula features in the article to be processed are obtained in the following steps. The formula features are features of all formulas in the article to be processed, and the formulas in the article to be processed are highly correlated with the category to which the article to be processed belongs.
[0132] By identifying the formula in the article to be processed and intercepting the area where the formula in the article to be processed is located to obtain the formula, it is ensured that the formula in the article to be processed is accurately collected.
[0133] Step 504: input the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the above-mentioned convolutional neural network training method.
[0134] Specifically, the convolutional neural network includes an input layer, an intermediate layer and a fully connected layer.
[0135] The formula in the article to be processed is input to the middle layer through the input layer of the convolutional neural network, and the middle layer processes the formula to obtain high-dimensional features.
[0136] The high-dimensional features are input into the fully connected layer of the convolutional neural network for normalization to obtain the formula features.
[0137] Convolutional neural networks can be used to extract formula features. The formula in the article to be processed is input into the convolutional neural network, and the fully connected layer of the convolutional neural network outputs the formula features corresponding to the article to be processed, thereby ensuring the accuracy of the information extracted from the formula in the article to be processed.
[0138] Step 506: Classify the articles to be processed according to the formula features corresponding to the articles to be processed.
[0139] Specifically, the classification of the articles to be processed includes unsupervised clustering and supervised classification. In unsupervised clustering, the data in the input sample data set is not labeled and there is no definite category result. The category of the sample data is unknown. It is necessary to cluster the sample set according to the similarity between the sample data so that the data gap within the category is minimized and the gap between the data in this category and the data in other categories is maximized.
[0140] Supervised classification is to learn the model parameters of a classification model from a given sample data set. Each data in the sample data set has a category label. The new data to be classified is input into the classification model, and the classification model predicts the category of the data to be classified.
[0141] The first classification method of the articles to be processed is to classify the articles to be processed into specific preset categories, and classify the articles to be processed through steps 602 to 610.
[0142] Step 602: Obtain standard articles belonging to a preset category.
[0143] The preset categories are category determination formulas collected by users themselves. For example, the preset categories are long short-term memory network category, machine translation category, and image processing category.
[0144] The standard article is an article belonging to a preset category, that is, the formula in the standard article is a typical formula of the preset category. For example, if the preset category is long short-term memory network, the standard article is a text containing a typical formula of the long short-term memory network. This ensures that the articles to be processed in the following steps can be accurately classified into the preset category.
[0145] Step 604: Collect formulas in the standard article.
[0146] Optionally, the formulas in the standard article may be collected through text recognition; or the formulas in the standard article may be identified and the area where the formulas are located in the standard article may be captured to obtain a formula image, thereby ensuring accurate collection of the formulas in the standard article.
[0147] Step 606: According to the formula in the standard article, obtain the formula feature corresponding to the standard article.
[0148] The convolutional neural network can be used to extract image features, and the formula image in the article to be processed is input into the convolutional neural network to obtain the formula features corresponding to the article to be processed output by the fully connected layer of the convolutional neural network, thereby ensuring the accuracy of the information extracted from the formula image in the article to be processed.
[0149] Step 608: Calculate the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article.
[0150] In this step, the cosine similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article can be calculated. The cosine similarity is evaluated by calculating the similarity value of the angle between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article.
[0151] Step 610: Classify the articles to be processed whose similarity exceeds a preset similarity threshold into preset categories.
[0152] The following describes the calculation process of the cosine similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article.
[0153] Assume that the formula feature A corresponding to an article to be processed is (1, 1, 2, 1, 1, 1, 0, 0, 0);
[0154] The formula feature B corresponding to the standard article belonging to the image processing category is (1, 1, 1, 0, 1, 1, 1, 1, 1).
[0155] The calculation formula of cosine similarity is as follows:
[0156]
[0157] Among them, cos(θ) is the cosine similarity value, x i is the formula feature A, y i is the formula feature B.
[0158] For formula features A and B, the similarity value is calculated as follows:
[0159]
[0160] The similarity value ranges from [-1,1]. The closer the similarity value is to 1, the closer the directions of the two vectors are, that is, the more similar the first entity is to the transliterated entity; the closer the similarity value is to -1, the more opposite the directions of the two vectors are, that is, the greater the difference between the first entity and the transliterated entity.
[0161] The similarity value between formula feature A and formula feature B is 0.802, which exceeds the preset similarity threshold of 0.6. Therefore, the formula feature of the article to be processed is basically similar to the formula feature corresponding to the standard entity belonging to the image processing class, so the article to be processed is classified into the image processing class.
[0162] If the similarity between the article to be processed and the standard article exceeds a preset similarity threshold, the article to be processed belongs to a preset category, which can improve the efficiency of obtaining the articles to be processed belonging to the preset category.
[0163] The second classification method of the articles to be processed is to cluster the articles to be processed, that is, among all the articles to be processed, the articles to be processed are divided into several different categories according to the clustering algorithm.
[0164] The clustering algorithm may be a k-nearest neighbor (KNN) algorithm, which is a basic classification and regression method. The basic principle is to find the k instance points closest to the test instance in the training set based on a certain distance metric, and then make predictions based on the information of the k nearest neighbors.
[0165] The specific algorithm principle is: 1) calculate the distance between the test data and each training data; 2) sort according to the increasing relationship of the distance; 3) select K points with the smallest distance; 4) determine the frequency of occurrence of the category of the first K points; 5) return the category with the highest frequency among the first K points as the predicted classification of the test data.
[0166] The clustering algorithm may be a mean-shift clustering algorithm, which is a centroid-based algorithm, that is, its goal is to locate the center point of each group or class by updating the center point candidate, and updating the center point candidate to the mean of the points in the sliding window. These candidate sliding windows will then be filtered in the post-processing stage to reduce adjacent duplicate points, and finally form a set of center points as a category.
[0167] Combine the following Figure 7a and Figure 7b The mean-shift algorithm is described. Specifically, 1) the formula features corresponding to each article to be processed are mapped to a two-dimensional space to form the following Figure 7a The point set shown, each point represents an article to be processed, starts with a circular sliding window centered at a randomly selected point and with a radius r as the kernel. At each step, the kernel is iteratively moved to a higher density area until it converges.
[0168] 2) At each iteration, the window is moved to a higher density region by moving the center point to the mean of the points in the window. The density in a window is proportional to the number of points inside it. Naturally, by moving the center to the mean of the points in the window, we can gradually move to a region with a high density.
[0169] 3) Continue to move the sliding window according to the mean of the points in the sliding window until there is a direction that can accommodate more points in the kernel. Keep moving the circle until the density no longer increases (that is, the number of points in the sliding window no longer increases).
[0170] 4) Repeat the process 1-3 with many sliding windows until all points are contained in the window. When multiple sliding windows overlap, the window containing the most points will be retained. Then, cluster the data points according to the sliding window in which the data points are located, for example, Figure 7b The final clustering result is shown, that is, the articles to be processed are divided into four categories.
[0171] In this embodiment, formula features in the article to be processed are obtained, formulas in the article to be processed are collected, and the formulas have a high correlation with the category to which the article to be processed belongs. The formula information in the article to be processed is used to calculate the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article, and the article to be processed is classified, especially for the situation where the category information is not in the text of the document and the category of the document cannot be identified. Therefore, the accuracy of document classification for which the category information is not in the text can be improved, thereby improving the efficiency of users retrieving target information in the data set.
[0172] The fourth embodiment of the present application provides a device for training a convolutional neural network, see Figure 8 As shown, including:
[0173] The collection module 802 is configured to obtain a sample article set, collect formulas in the sample article set to obtain a formula set;
[0174] The training module 804 is configured to take a single formula in the formula set as a positive sample, take other single formulas in the sample article where the single formula is located as positive examples, take formulas in other sample articles as negative examples, and input the positive samples, positive examples and negative examples into a convolutional neural network for training until the training stop condition is reached.
[0175] Optionally, the training module 804 is further configured to:
[0176] Inputting the positive sample, positive example and negative example into a convolutional neural network to obtain positive sample features, positive example features and negative example features respectively;
[0177] The distance between the positive sample feature and the positive example feature and the distance between the positive sample feature and the negative example feature are calculated respectively, and the difference between the two distances is calculated by using a marginal loss function;
[0178] According to the difference, the weight value of each layer of neuron nodes is adjusted in turn from the fully connected layer to the input layer of the convolutional neural network, the current training is completed, and the next training is continued until the training stop condition is reached.
[0179] Optionally, the training stop condition includes: the rate of change of the difference is less than a preset stability threshold.
[0180] Optionally, the convolutional neural network training device further includes:
[0181] An extraction module is configured to extract a keyword from a sample article abstract where a single formula is located, and use the keyword as a label corresponding to the single formula;
[0182] A processing module is configured to take the single formula as a positive sample, take formulas in other sample articles as negative samples, and input the positive sample, the label corresponding to the positive sample, the negative sample and the label corresponding to the negative sample into a convolutional neural network to obtain positive sample features and negative sample features;
[0183] The pre-training module is configured to calculate a loss value based on the positive sample features and the labels corresponding to the positive samples and the negative sample features and the labels corresponding to the negative samples, and adjust the parameters of the convolutional neural network according to the loss value until the pre-training stop condition is reached.
[0184] In this embodiment, the convolutional neural network is trained to achieve the training purpose of making positive examples more similar to positive samples and negative examples dissimilar to positive samples, that is, to make any two formulas in the same sample article have a high correlation. During the use of the trained convolutional neural network, the trained convolutional neural network is used to extract the features of the formulas in the article to be processed, so that the correlation between similar formulas is high, thereby ensuring the accuracy of the information extracted from all formulas in the article to be processed.
[0185] The fifth embodiment of the present application provides a device for article classification, see Fig. 9 As shown, including:
[0186] A receiving module 902 is configured to receive an article to be processed and obtain a formula in the article to be processed;
[0187] The acquisition module 904 is configured to input the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the above-mentioned convolutional neural network training method;
[0188] The classification module 906 is configured to classify the article to be processed according to the formula features corresponding to the article to be processed.
[0189] The convolutional neural network includes an input layer, an intermediate layer and a fully connected layer;
[0190] The acquisition module 904 is further configured to input the formula in the article to be processed into the middle layer through the input layer of the convolutional neural network, and the middle layer processes the formula to obtain high-dimensional features; and input the high-dimensional features into the fully connected layer of the convolutional neural network for normalization to obtain formula features.
[0191] Optionally, the classification module 906 is further configured to: obtain standard articles belonging to a preset category;
[0192] Collecting formulas from the standard article;
[0193] According to the formula in the standard article, obtaining the formula feature corresponding to the standard article;
[0194] Calculating the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article;
[0195] The articles to be processed whose similarity exceeds a preset similarity threshold are classified into preset categories.
[0196] Optionally, the classification module 906 is further configured to:
[0197] Obtaining the grouped texts in each group, and collecting the formulas in the grouped texts;
[0198] According to the formula in the grouped text, obtaining the formula feature corresponding to the grouped text;
[0199] Calculating the original distance between the formula feature corresponding to the article to be processed and the formula feature corresponding to each of the grouped texts one by one;
[0200] Acquire the grouped texts whose original distance is less than the preset distance as screening texts, and determine the number of screening texts whose original distance is less than the preset distance in each group;
[0201] The articles to be processed are divided into the group containing the largest number of filtered texts.
[0202] In this embodiment, by obtaining the formula features in the article to be processed and collecting the formulas in the article to be processed, the formulas have a high correlation with the category to which the article to be processed belongs, and using the formula information in the article to be processed to calculate the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article, the article to be processed is classified, thereby improving the efficiency of users retrieving target information in the data set.
[0203] An embodiment of the present application also provides a computing device, including a memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein when the processor executes the instructions, the steps of the method for training a convolutional neural network or the method for classifying an article as described above are implemented.
[0204] An embodiment of the present application also provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the method for training a convolutional neural network or the method for classifying articles as described above.
[0205] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned convolutional neural network training method or article classification method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned convolutional neural network training method or article classification method.
[0206] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0207] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0208] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0209] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is limited only by the claims and their full scope and equivalents.
Claims
1. A method for training a convolutional neural network, characterized in that: include: Obtain a sample article set, and collect formulas in the sample article set to obtain a formula set; A single formula in the formula set is used as a positive sample, other single formulas in the sample article where the single formula is located are used as positive examples, and formulas in other sample articles are used as negative examples, and the positive samples, positive examples and negative examples are input into a convolutional neural network for training until a training stop condition is reached; Before inputting the positive samples, positive examples and negative examples into the convolutional neural network for training, the method further includes: The abstract keywords corresponding to the single formula are used as the labels corresponding to the positive samples, the formulas in the other sample articles are used as negative samples, and the randomly selected abstract keywords are used as the labels corresponding to the negative samples and input into the convolutional neural network for pre-training.
2. The method according to claim 1, characterized in that Inputting the positive samples, positive examples and negative examples into the convolutional neural network for training until the training stop condition is reached includes: Inputting the positive sample, positive example and negative example into a convolutional neural network to obtain positive sample features, positive example features and negative example features respectively; The distance between the positive sample feature and the positive example feature and the distance between the positive sample feature and the negative example feature are calculated respectively, and the difference between the two distances is calculated by using a marginal loss function; According to the difference, the weight value of each layer of neuron nodes is adjusted in turn from the fully connected layer to the input layer of the convolutional neural network, the current training is completed, and the next training is continued until the training stop condition is reached.
3. The method according to claim 2, characterized in that The training stop conditions include: The difference change rate is less than a preset stability threshold.
4. The method according to claim 1, characterized in that: Before inputting the positive samples, positive examples and negative examples into the convolutional neural network for training, the method further includes: Extracting keywords from the sample article where the single formula is located, and using the keywords as labels corresponding to the single formula; Taking the single formula as a positive sample and the formulas in other sample articles as negative samples, the positive sample, the label corresponding to the positive sample, the negative sample and the label corresponding to the negative sample are input into a convolutional neural network to obtain positive sample features and negative sample features; A loss value is calculated based on the positive sample features and the labels corresponding to the positive samples and the negative sample features and the labels corresponding to the negative samples, and the parameters of the convolutional neural network are adjusted according to the loss value until the pre-training stop condition is reached.
5. A method for article classification, characterized in that: include: Receiving an article to be processed, and obtaining a formula in the article to be processed; Inputting the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the convolutional neural network training method according to any one of claims 1 to 4; The articles to be processed are classified according to formula features corresponding to the articles to be processed.
6. The method according to claim 5, characterized in that The convolutional neural network includes an input layer, an intermediate layer and a fully connected layer; Inputting the formula in the article to be processed into the convolutional neural network, and obtaining the formula features corresponding to the article to be processed output by the convolutional neural network, including: The formula in the article to be processed is input to the middle layer through the input layer of the convolutional neural network, and the middle layer processes the formula to obtain high-dimensional features; The high-dimensional features are input into the fully connected layer of the convolutional neural network for normalization to obtain the formula features.
7. The method according to claim 5, characterized in that Classifying the articles to be processed according to the formula features in the articles to be processed includes: Get standard articles belonging to preset categories; Collecting formulas from the standard article; According to the formula in the standard article, obtaining the formula feature corresponding to the standard article; Calculating the similarity between the formula features corresponding to the article to be processed and the formula features corresponding to the standard article; The articles to be processed whose similarity exceeds a preset similarity threshold are classified into preset categories.
8. The method according to claim 5, characterized in that Classifying the articles to be processed according to the formula features in the articles to be processed includes: Obtaining the grouped texts in each group, and collecting the formulas in the grouped texts; According to the formula in the grouped text, obtaining the formula feature corresponding to the grouped text; Calculating the original distance between the formula feature corresponding to the article to be processed and the formula feature corresponding to each of the grouped texts one by one; Acquire the grouped texts whose original distance is less than the preset distance as screening texts, and determine the number of screening texts whose original distance is less than the preset distance in each group; The articles to be processed are divided into the group containing the largest number of filtered texts.
9. A device for training a convolutional neural network, characterized in that: include: A collection module is configured to obtain a sample article set, collect formulas in the sample article set to obtain a formula set; A training module is configured to take a single formula in the formula set as a positive sample, take other single formulas in the sample article where the single formula is located as positive examples, take formulas in other sample articles as negative examples, and input the positive sample, positive examples and negative examples into a convolutional neural network for training until a training stop condition is reached; The training module is further configured to use the summary keywords corresponding to the single formula as the labels corresponding to the positive samples, use the formulas in the other sample articles as negative samples, and input the randomly selected summary keywords as the labels corresponding to the negative samples into the convolutional neural network for pre-training.
10. A device for classifying articles, characterized in that: include: A receiving module is configured to receive an article to be processed and obtain a formula in the article to be processed; An acquisition module is configured to input the formula in the article to be processed into a convolutional neural network to obtain the formula features corresponding to the article to be processed output by the convolutional neural network, wherein the convolutional neural network is trained by the convolutional neural network training method according to any one of claims 1 to 4; The classification module is configured to classify the articles to be processed according to the formula features corresponding to the articles to be processed.
11. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, characterized in that: When the processor executes the instructions, the steps of the method described in any one of claims 1-4 or claims 5-8 are implemented.
12. A computer-readable storage medium storing computer instructions, characterized in that: When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 4 or claims 5 to 8 are implemented.
Citation Information
Patent Citations
Method and device for establishing picture search correlation prediction model, and picture search method and device
CN106021364A
Method for testing color matching of colored spun yarn through computer
CN107766603A
Automatic labeling method and device for mathematic question knowledge points
CN108182177A
Question classification method and device, electronic equipment and storage medium
CN109685137A
Method for reducing over-fitting of network training during offline handwritten mathematical formula recognition
CN110084239A
