A text distribution adversarial training method and device for a neural network model, and a sentiment analysis method
Through the adversarial training method, Monte Carlo sampling is used to obtain adversarial distribution, enhance the robustness of the neural network model, solve the problem of adversarial attacks, and improve the accuracy and security of sentiment analysis.
Patent Information
- Application Number
- CN202211279288.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-19
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-10-19
AI Technical Summary
Existing neural network models show vulnerability in the face of adversarial attacks and are easily deceived by maliciously constructed adversarial samples, resulting in wrong decision-making, especially in risk-sensitive scenarios.
The text distribution adversarial training method of neural network model is adopted, and the adversarial distribution of training data is obtained through Monte Carlo sampling, and the adversarial samples are input into the model to optimize the model parameters to enhance its ability and robustness against attacks.
It improves the robustness of the model, enhances the ability to fight attacks, improves the accuracy of sentiment analysis, and prevents misjudgment caused by interference from malicious comments.
Smart Images

Figure CN115658893B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a text distribution adversarial training method and device for a neural network model, and a sentiment analysis method. Background Art
[0002] With the advent of the big data era and the continuous breakthroughs in AI-related theories and technologies, deep learning, a research hotspot and core technology in the field of AI, has been widely applied to various research fields such as computer vision, natural language processing, and speech recognition, achieving tremendous success. Simultaneously, a large number of deep learning technologies are maturing and gradually being implemented in industry, greatly promoting the large-scale and industrialized development of deep learning. For example, in the field of computer vision, deep learning-driven face recognition and object detection models, as core components of intelligent security systems, have become powerful tools for protecting the lives and property of the public.
[0003] In the field of natural language processing, deep learning-based text processing and understanding technologies have achieved breakthroughs in core tasks such as text classification, machine translation, and human-computer dialogue, spawning a series of important real-world applications such as sentiment analysis, online harmful text detection, spam filtering, and intelligent customer service. In the field of speech recognition, according to data released by the China Speech Industry Alliance, the global intelligent speech market will exceed US$10 billion in 2017, with the domestic market projected to grow at a five-year compound annual growth rate of over 60%. Driven by technology giants such as Microsoft, Baidu, AISpeech, and iFlytek, deep learning-driven speech recognition technology has rapidly developed in voice assistants, smart homes, and smart cars, significantly enriching and improving people's lives.
[0004] However, despite their widespread real-world applications and impressive performance, deep neural network models also face numerous security threats. Recent research has shown that even highly performing deep neural network models are significantly vulnerable to maliciously constructed adversarial examples. Attackers can easily trick a target neural network model used for image classification tasks by adding carefully crafted, human-imperceptible adversarial perturbations to naturally occurring images, causing the classification model to make incorrect decisions regarding the perturbed adversarial images while remaining unaffected by human judgment. Because this type of attack relies on constructing adversarial examples that cause the target model to misclassify, it is known as an adversarial example attack, also known as an adversarial attack. First discovered in the field of computer vision, adversarial attacks have now expanded to fields such as speech recognition, natural language processing, and graph data analysis. Due to their concealed nature and potentially detrimental nature, they pose a serious threat to the security of deep learning models deployed in real-world scenarios, particularly those in risk-sensitive scenarios such as autonomous driving, harmful content detection, and spam filtering. For example, according to relevant reports, attackers only need to use a color printer to print out specific adversarial samples and stick them on a hat to break the industry's leading open source facial recognition system. This shows that intelligent systems based on facial recognition such as face unlocking, face payment, and smart security are no longer safe.
[0005] In recent years, adversarial attacks have become increasingly serious and have become the primary threat in the field of artificial intelligence security, causing great concern and attracting widespread attention and in-depth research from academia and industry. Summary of the Invention
[0006] The present invention provides a text distribution adversarial training method and device for a neural network model, and a sentiment analysis method, which are used to solve or at least partially solve the problem that the sentiment analysis model obtained by the method in the prior art is not strong in adversarial attack.
[0007] In order to solve the above technical problems, the first aspect of the present invention provides a text distribution adversarial training method for a neural network model, comprising:
[0008] S1: Get the training dataset;
[0009] S2: Build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information.
[0010] S3: Conduct text-based adversarial distribution training on the constructed sentiment analysis model, specifically including: reading samples from the training dataset, each sample consists of a comment and its corresponding label, adding a loss function during the training process, inputting a batch of samples, and then performing distribution prediction on each sample. The distribution of each sample is Gaussian distribution, and the mean of Gaussian distribution is The variance is An initialized noise is added to the word embedding vector of each sample, and a prediction is made. The predicted result is compared with the label, and the noise is optimized based on the comparison result to obtain the adversarial distribution of the sample; each sample with the adversarial distribution is input into the sentiment analysis model for training, and the model parameters are adjusted to obtain a trained sentiment analysis model.
[0011] In one embodiment, during the text-based adversarial distribution training process of step S3, a gradient descent algorithm is used to optimize the noise, and a Monte Carlo sampling method is used to estimate the Gaussian distribution of each sample, specifically including: sampling each sample m times and then performing T steps of gradient ascent.
[0012] In one embodiment, variational inference is used to estimate the adversarial distribution of samples.
[0013] In one embodiment, the adversarial distribution of the sample obtained in step S3 is in the form of:
[0014]
[0015] in represents the loss function, f θ represents the classifier, refers to the i-th sample, Refers to Added noise, yes The label, n is the number of samples, is a collection of noises.
[0016] Based on the same inventive concept, the second aspect of the present invention provides a sentiment analysis method, which inputs the comments to be analyzed into the trained sentiment analysis model obtained in the first aspect to obtain sentiment analysis results.
[0017] Based on the same inventive concept, the second aspect of the present invention provides a text distribution adversarial training device for a neural network model, comprising:
[0018] Data set acquisition module, used to obtain training data sets;
[0019] The model building module is used to build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information.
[0020] The model training module is used to perform text-based adversarial distribution training on the constructed sentiment analysis model. Specifically, it includes: reading samples from the training data set, each sample consists of a comment and its corresponding label. During the training process, a loss function is added, a batch of samples are input, and then a distribution prediction is performed on each sample. The distribution of each sample is Gaussian distribution, and the mean value of Gaussian distribution is The variance is An initialized noise is added to the word embedding vector of each sample, and a prediction is made. The predicted result is compared with the label, and the noise is optimized based on the comparison result to obtain the adversarial distribution of the sample; each sample with the adversarial distribution is input into the sentiment analysis model for training, and the model parameters are adjusted to obtain a trained sentiment analysis model.
[0021] Based on the same inventive concept, the fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the program is executed.
[0022] Based on the same inventive concept, the fifth aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.
[0023] Compared with the prior art, the advantages and beneficial technical effects of the present invention are as follows:
[0024] The present invention proposes a text-based adversarial distribution training method for a neural network model. The neural network model is a sentiment analysis model. During the training process, according to the characteristics of the adversarial attack, the adversarial distribution of the training data (including multiple samples) is obtained through Monte Carlo sampling. The adversarial samples are input into the neural network for training, thereby obtaining a trained model, enhancing its ability to resist attacks, and improving the robustness of the model.
[0025] Furthermore, a method for performing sentiment analysis using a model obtained based on the above-mentioned text-based adversarial distribution training method is provided, thereby improving the accuracy of sentiment analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0027] Figure 1 This is a schematic diagram of the overall process of a text distribution adversarial training method for a neural network model disclosed in an embodiment of the present invention;
[0028] Figure 2 is a flow chart of the training process disclosed in an embodiment of the present invention;
[0029] Figure 3 A schematic diagram of the structure of a computer-readable storage medium provided in an embodiment of the present invention;
[0030] Figure 4 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0031] This invention primarily exploits the fact that neural networks are susceptible to countermeasure attacks. By using Monte Carlo sampling to obtain the adversarial distribution of training data, this method then inputs adversarial samples into the neural network for training, thereby enhancing its robustness. The resulting model is more accurate and robust.
[0032] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0033] Example 1
[0034] An embodiment of the present invention provides a text distribution adversarial training method for a neural network model, comprising:
[0035] S1: Get the training dataset;
[0036] S2: Build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information.
[0037] S3: Conduct text-based adversarial distribution training on the constructed sentiment analysis model, specifically including: reading samples from the training dataset, each sample consists of a comment and its corresponding label, adding a loss function during the training process, inputting a batch of samples, and then performing distribution prediction on each sample. The distribution of each sample is Gaussian distribution, and the mean of Gaussian distribution is The variance is An initialized noise is added to the word embedding vector of each sample, and a prediction is made. The predicted result is compared with the label, and the noise is optimized based on the comparison result to obtain the adversarial distribution of the sample; each sample with the adversarial distribution is input into the sentiment analysis model for training, and the model parameters are adjusted to obtain a trained sentiment analysis model.
[0038] Specifically, to address the existing problem of specially processed text being "scammed" through, resulting in significant economic and reputational losses, a text-based adversarial distribution training method is proposed to improve the user experience and construct a neural network, thereby enhancing the robustness of existing models. Currently, many film and television review websites and shopping sites, such as Douban and Taobao, need to classify film and television reviews into positive and negative categories and list them separately. However, due to the large number of reviews, manual review is not possible, so trained neural networks are used to review them. However, these neural networks may be interfered with by malicious comments, leading to incorrect judgments. The method of the present invention is primarily intended to prevent this from occurring.
[0039] See Figure 1 , is an overall flow chart of the text distribution adversarial training method of the neural network model disclosed in an embodiment of the present invention.
[0040] In the specific real-time process, the training data set in S1 can be extracted from user data or use other tested data sets.
[0041] This embodiment is aimed at the sentiment analysis model. For the word embedding model, its input data sample consists of a comment and its corresponding label. In the label, 1 represents "positive" and 0 represents "negative". If more emotional states are needed, further division can be performed. For example, five emotional state analyses can be performed, and 1-5 represent one emotional state respectively. Then each comment needs to be segmented to obtain comments with good word segmentation. For example, the get_tokenized_imd function can be used for word segmentation, which mainly distinguishes each word. The simplest method is used: word segmentation based on spaces. After that, a dictionary can be created based on the training data set with good word segmentation. Specifically, words that appear less than 5 times can be filtered out. A data iterator needs to be created afterwards. Each iteration will return a small batch of data. In this word embedding model, each word first passes through the embedding layer to obtain a feature vector.
[0042] In the second network, a bidirectional recurrent neural network is then used to further encode the feature sequence to obtain sequence information. This encoded sequence information is then transformed into an output through a fully connected layer. Specifically, the hidden states of the bidirectional long short-term memory at the initial and final time steps are concatenated and passed to the output layer as a representation of the feature sequence for classification. In the BiRNN class, the Embedding instance is the embedding layer, the LSTM instance is the hidden layer for sequence encoding, and the Linear instance is the output layer for generating the classification results. Since the training dataset for sentiment classification is not very large, to prevent overfitting, word vectors pre-trained on a larger corpus can be used as the feature vector for each word. In this embodiment, a 100-dimensional GloVe word vector is loaded for each word in the vocabulary. These word vectors are then used as the feature vector for each word in the review. It should be noted that the dimensions of the pre-trained word vectors must match the embedding layer output size (embed_size) in the created model. Furthermore, these word vectors are not updated during training. The purpose of word vectors is to establish connections between each word. The machine does not know the meaning of each word, so these connections need to be manually created.
[0043] In one embodiment, during the text-based adversarial distribution training process of step S3, a gradient descent algorithm is used to optimize the noise, and a Monte Carlo sampling method is used to estimate the Gaussian distribution of each sample, specifically including: sampling each sample m times and then performing T steps of gradient ascent.
[0044] See Figure 2 , is a flow chart of the training process disclosed in an embodiment of the present invention.
[0045] During the specific implementation process, it is determined whether the output result of the model is consistent with the label of the sample. If it is consistent, the adversarial distribution of the sample is input into the model. If it is inconsistent, the gradient descent algorithm is used to optimize the noise.
[0046] In one embodiment, the adversarial distribution of the sample obtained in step S3 is in the form of:
[0047]
[0048] in represents the loss function, f θ represents the classifier, refers to the i-th sample, Refers to Added noise, yes The label, n is the number of samples, is a collection of noises.
[0049] In the specific implementation process, the pseudo code of the text distribution adversarial training method (T-ADT) used is shown in Table 1:
[0050]
[0051] During the training process, a core loss function needs to be added, which is also the core of distribution training. First, a batch_size sample is input, and then the distribution prediction is performed for each sample. This embodiment uses the reparameterization technique, assuming that the distribution of each sample is Gaussian distribution, and the mean of the distribution is set to The variance is Initialized noise is added to the word embedding vector of each sample, a prediction is performed, the prediction result is compared with its label, and the noise is optimized using a gradient descent algorithm. This embodiment uses the Monte Carlo sampling method to estimate the Gaussian distribution of each sample. Each sample is sampled n times, and then a gradient ascent is performed for T steps to finally obtain the adversarial distribution of the sample.
[0052] In other embodiments, there is an architecture that does not use Monte Carlo sampling to estimate the adversarial distribution of samples, but instead uses variational inference to estimate the adversarial distribution of samples. Although the aforementioned method provides a simple way to learn explicit adversarial distributions for T-ADT (Text Distribution Adversarial Training), it requires learning the distribution parameters of each input, which then brings prohibitive computational costs. Compared with previous AT (Adversarial Training) based on adversarial attacks, T-ADT EXP (Explicit text distribution adversarial training) is about k times slower because φ i The gradient of is estimated by k Monte Carlo samples at each step. Therefore, T-ADT can be EXP , to develop a more feasible and scalable training method.
[0053] Choose to learn a mapping where g φ is a distribution function, It refers to the dimension, refers to the target distribution. Instead of learning each data x i The distribution parameters of this mapping conditionally define the adversarial distribution p for each input φ (δ i |x i ). This embodiment instantiates g through a condition generator network. φ It takes a natural example x i is the input and outputs the parameter (μ i ,σi ), the characteristic of this approach is that the generator network can potentially learn the common structure of adversarial perturbations, which can be generalized to other training samples. This means that we do not need to i Over-optimizing φ on φ can speed up training.
[0054] There are two assumptions required at this step: First, assume that the loss function is continuously differentiable;
[0055] Second, the probability density distribution function of P is bounded and equally likely.
[0056] Table 2 Results of the verification experimental system
[0057]
[0058] Among them, CNN is a convolutional neural network, RNN is a recurrent neural network, IMDB is a film and television review dataset, ORIG is a clean sample model, RAN is a text adversarial defense method, T-ADT is the method proposed in this invention, CLN is a clean dataset, PWWS is an attack algorithm based on probability weighted word saliency, GA is a genetic-based attack algorithm, and UAT is a gradient-based word or character operation attack algorithm. The values in the table are the adversarial samples obtained using attack algorithms such as PWWS to verify the accuracy of defense methods such as RAN.
[0059] By inputting each sample with its adversarial distribution into the neural network model for training, a model with strong robustness can be obtained. In the experiment, we tested the model (ORIG,) with various attacks (PWWS, GA). The results show that the accuracy of the method of the present invention (T-ADT) is higher than that of other methods. The method of the present invention is effective. Please see Table 2 for details.
[0060] Example 2
[0061] Based on the same inventive concept, this embodiment provides a sentiment analysis method, which inputs the comments to be analyzed into the trained sentiment analysis model obtained in the first embodiment to obtain sentiment analysis results.
[0062] This embodiment is a specific application of the model trained in the embodiment. By inputting the comment data to be analyzed into the model, sentiment analysis results can be obtained.
[0063] Example 3
[0064] Based on the same inventive concept, this embodiment provides a text distribution adversarial training device for a neural network model, comprising:
[0065] Data set acquisition module, used to obtain training data sets;
[0066] The model building module is used to build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information.
[0067] The model training module is used to perform text-based adversarial distribution training on the constructed sentiment analysis model. Specifically, it includes: reading samples from the training data set, each sample consists of a comment and its corresponding label. During the training process, a loss function is added, a batch of samples are input, and then a distribution prediction is performed on each sample. The distribution of each sample is Gaussian distribution, and the mean value of Gaussian distribution is The variance is An initialized noise is added to the word embedding vector of each sample, and a prediction is made. The predicted result is compared with the label, and the noise is optimized based on the comparison result to obtain the adversarial distribution of the sample; each sample with the adversarial distribution is input into the sentiment analysis model for training, and the model parameters are adjusted to obtain a trained sentiment analysis model.
[0068] Since the device described in Example 3 of the present invention is the device used to implement the text distribution adversarial training method of the neural network model in Example 1 of the present invention, based on the method described in Example 1 of the present invention, those skilled in the art will be able to understand the specific structure and variations of the device, so they will not be described in detail here. All devices used in the method in Example 1 of the present invention fall within the scope of protection of the present invention.
[0069] Example 4
[0070] Based on the same inventive concept, see Figure 3 The present invention further provides a computer-readable storage medium 300 on which a computer program 311 is stored. When the program is executed, the method described in the first embodiment is implemented.
[0071] Since the computer-readable storage medium described in the fourth embodiment of the present invention is the computer-readable storage medium used to implement the text distribution adversarial training method of the neural network model in the first embodiment of the present invention, based on the method described in the first embodiment of the present invention, those skilled in the art can understand the specific structure and variations of the computer-readable storage medium, so they are not described in detail here. All computer-readable storage media used in the method of the first embodiment of the present invention fall within the scope of protection of the present invention.
[0072] Example 5
[0073] Based on the same inventive concept, the present application also provides a computer device, such as Figure 4 As shown, it includes a memory 401, a processor 402 and a computer program 403 stored in the memory and executable on the processor. When the processor executes the above program, the method in the first embodiment is implemented.
[0074] Since the computer device described in Example 5 of the present invention is the computer device used to implement the text distribution adversarial training method of the neural network model in Example 1 of the present invention, based on the method described in Example 1 of the present invention, those skilled in the art will be able to understand the specific structure and variations of the computer device, so they will not be described in detail here. All computer devices used in the method of Example 1 of the present invention fall within the scope of protection of the present invention.
[0075] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0076] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0077] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0078] Obviously, those skilled in the art may make various changes and modifications to the embodiments of the present invention without departing from the spirit and scope of the embodiments of the present invention. Thus, if such changes and modifications of the embodiments of the present invention fall within the scope of the claims and their equivalents, the present invention is intended to include such changes and modifications.
Claims
1. A text distribution adversarial training method for a neural network model, characterized in that: include: S1: Get the training dataset; S2: Build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information. S3: Conduct text-based adversarial distribution training on the constructed sentiment analysis model, specifically including: reading samples from the training dataset, each sample consists of a comment and its corresponding label, adding a loss function during the training process, inputting a batch of samples, and then performing distribution prediction on each sample. The distribution of each sample is Gaussian distribution, and the mean of Gaussian distribution is , the variance is , add an initialized noise to the word embedding vector of each sample, make a prediction, compare the prediction result with the label, and optimize the noise according to the comparison result to obtain the adversarial distribution of the sample; input each sample with the adversarial distribution into the sentiment analysis model for training, adjust the model parameters, and obtain a trained sentiment analysis model; Among them, the adversarial distribution of the sample is estimated using variational inference, specifically: Choose to learn a mapping ,in represents a distribution function, Represents the dimension, Represents the target distribution, mapping Conditionally define the adversarial distribution for each input , rather than learning each data The distribution parameters of , which takes a natural example As input, and output parameters .
2. The text distribution adversarial training method for a neural network model according to claim 1, wherein: During the text-based adversarial distribution training process in step S3, the gradient descent algorithm is used to optimize the noise, and the Monte Carlo sampling method is used to estimate the Gaussian distribution of each sample, specifically including: sampling each sample m times and then performing T steps of gradient ascent.
3. The text distribution adversarial training method for a neural network model according to claim 1, wherein: The adversarial distribution of the sample obtained in step S3 is in the form of: in represents the loss function, represents the classifier, refers to the i-th sample, Refers to Added noise, yes Tags, is the number of samples, is a collection of noises.
4. A sentiment analysis method, characterized in that: The comments to be analyzed are input into the trained sentiment analysis model obtained according to any one of claims 1 to 3 to obtain sentiment analysis results.
5. A text distribution adversarial training device for a neural network model, characterized in that: A method for implementing text distribution adversarial training of a neural network model according to claim 1, the device comprising: Data set acquisition module, used to obtain training data sets; The model building module is used to build a sentiment analysis model. The sentiment analysis model includes a word embedding model and a bidirectional recurrent neural network. The word embedding model is used to obtain word embeddings based on the input words. The bidirectional recurrent neural network further encodes the feature sequence formed by the word embeddings to obtain sequence information and obtain the sentiment analysis results of the sequence information. The model training module is used to perform text-based adversarial distribution training on the constructed sentiment analysis model. Specifically, it includes: reading samples from the training data set, each sample consists of a comment and its corresponding label. During the training process, a loss function is added, a batch of samples are input, and then a distribution prediction is performed on each sample. The distribution of each sample is Gaussian distribution, and the mean value of Gaussian distribution is , the variance is , add an initialized noise to the word embedding vector of each sample, make a prediction, compare the predicted result with the label, and optimize the noise according to the comparison result to obtain the adversarial distribution of the sample; input each sample with the adversarial distribution into the sentiment analysis model for training, adjust the model parameters, and obtain a trained sentiment analysis model.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed, the text distribution adversarial training method of the neural network model as described in any one of claims 1 to 3 is implemented.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the text distribution adversarial training method of the neural network model according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
E-commerce evaluation sentiment analysis method integrating GAN and transfer learning
CN110008338A
Image classification method and system based on adversarial distribution training
CN111488904A