CN114461791A - Social text sentiment analysis system based on deep quantum neural network - Google Patents

Social text sentiment analysis system based on deep quantum neural network Download PDF

Info

Publication number
CN114461791A
CN114461791A CN202111350644.XA CN202111350644A CN114461791A CN 114461791 A CN114461791 A CN 114461791A CN 202111350644 A CN202111350644 A CN 202111350644A CN 114461791 A CN114461791 A CN 114461791A
Authority
CN
China
Prior art keywords
quantum
text
neural network
time
vqc
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111350644.XA
Other languages
Chinese (zh)
Inventor
刘宇鹏
冯贤杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Harbin University of Science and Technology
Original Assignee
Harbin University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Harbin University of Science and Technology filed Critical Harbin University of Science and Technology
Priority to CN202111350644.XA priority Critical patent/CN114461791A/en
Publication of CN114461791A publication Critical patent/CN114461791A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/044Recurrent networks, e.g. Hopfield networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/048Activation functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Abstract

A social text sentiment analysis system based on a deep quantum neural network belongs to the technical field of intersection of quantum computing and natural language processing. The invention solves the problems of large storage overhead, high time complexity and low prediction precision of the existing deep learning method. The invention provides an adjustable parameter sub-deep learning method for social text sentiment analysis, the used quantum computation only needs to store input and output without storing intermediate results, so that the storage space of binary codes is saved, the problem of high storage cost of the binary codes is solved, and the quantum parallel computation does not need to gradually compute the classical computation of each deep neural network, so that the time complexity of the deep neural networks is reduced. The method can obtain a better model by adopting staged training, and has higher prediction precision and stronger robustness compared with the prior method. The method and the device can be applied to analyzing social text emotion.

Description

Social text sentiment analysis system based on deep quantum neural network
Technical Field
The invention belongs to the technical field of intersection of quantum computing and natural language processing, and particularly relates to a social text sentiment analysis system based on a deep quantum neural network.
Background
Emotional analysis of social media topics aims to explore the opinions and attitudes of people on a social network about a certain topic or event. The popularity of the internet has made people aware of the increasing and convenience of information channels. The amount of active daily users of the Xinlang as a large social network platform in China already exceeds 2.24 hundred million people, and the total number of the comments issued each day is as much as two hundred million on average. The social media mass data contains rich real-time information. People can push life dynamics and opinions to a social media platform and can also comment on popular events. The data with subjective colors bring great convenience to the research of emotion analysis.
The social text data has real-time performance and timeliness, and the value of the data can be more greatly exerted by capturing the timeliness of the social text information and analyzing the latest topic data. At present, most of research aiming at social text emotion analysis is focused on improving the analysis performance of an emotion analyzer by using a deep learning method, but the deep learning method is based on binary coding, so that the coding is 0 or 1, a large amount of time consumption, storage overhead and high time complexity are caused, and the problem is more obvious particularly under the conditions of large data volume and excessive neural network parameters. Moreover, the existing deep learning method has low social text emotion prediction precision.
Disclosure of Invention
The invention aims to solve the problems of high storage cost, high time complexity and low prediction precision of the conventional deep learning method, and provides a social text sentiment analysis system based on a deep quantum neural network.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a social text sentiment analysis system based on a deep quantum neural network comprises a data acquisition module, a data processing module, a text sequence information acquisition model and a sentiment analysis model, wherein:
the data acquisition module is used for acquiring an emotion classification data set, and the emotion classification data set comprises comment texts and labels corresponding to the comment texts;
the data processing module is used for segmenting the comment texts in the acquired emotion classification data set to obtain a comment text word sequence, and then mapping the comment text word sequence into a word vector space to obtain vectorized text sequence information;
the text sequence information acquisition model is trained by utilizing the comment text word sequence obtained by the data processing module and the corresponding vectorized text sequence information, and the output of the trained text sequence information acquisition model is vectorized text sequence information;
the emotion analysis model comprises a quantum long-time and short-time memory neural network and a network fusion module, wherein the quantum long-time and short-time memory neural network comprises an Input layer, a QLSTM layer and a full connection layer, and the QLSTM layer comprises t QLSTM units;
the quantum long-short term memory neural network utilizes vectorization text sequence information and labels corresponding to data in the emotion classification data set to pre-train, after n pre-trained quantum long-short term memory neural networks are obtained, the network fusion module fuses the n pre-trained quantum long-short term memory neural networks, and the output of the fused quantum long-short term memory neural networks is used as the output of the emotion analysis model;
after the comment text to be analyzed is segmented, obtaining a comment text word sequence to be analyzed; inputting a comment text word sequence to be analyzed into a trained text sequence information acquisition model, and acquiring vectorized text sequence information corresponding to the comment text to be analyzed;
and inputting the vectorized text sequence information corresponding to the comment text to be analyzed into an emotion analysis model, and outputting an emotion analysis result of the comment text to be analyzed.
Further, the data acquired by the data acquisition module further comprises a target data set, and the data format of the target data set is the same as that of the emotion classification data set, namely the target data set comprises comment texts and labels corresponding to the comment texts;
and fine-tuning the pre-trained emotion analysis model by utilizing vectorization text sequence information corresponding to the comment text in the target data set and the label to obtain a final emotion analysis model.
Further, the emotion classification data set is obtained by crawling on a new wave, and a Scapy distributed crawler framework is adopted in the crawling mode;
the target data set is a data set which is sorted and published from hotel comments of the cellular network in 2018.
Further, the QLSTM unit is defined as:
vt=ht-1*xt
ft=Activate(VQC1(vt))
it=Activate(VQC2(vt))
Figure RE-GDA0003510186100000021
Figure RE-GDA0003510186100000022
ot=Activate(VQC4(vt))
ht=VQC5(ot*Activate(ct))
yt=VQC6(ot*Activate(ct))
wherein x istIs the input vector at time t of the QLSTM cell, ht-1Is a hidden state at time t-1, vtIs an input vector of VQC cell body time t, Activate (r) is an activation function, ftForgetting gate vector, i, at time ttFor the input gate vector at time t,
Figure RE-GDA0003510186100000031
temporary cell state at time t, ct-1The cell state at time t-1, ctThe cell state at time t, otIs the output gate vector at time t, htHidden state at time t, ytFor the output state at time t, VQC1、VQC2、VQC3、VQC4、VQC5、VQC6Respectively represent the 1 st, 2 nd, 3 rd, 4 th, 5 th and 6 th VQC cell bodies.
Further, the activation function Activate is a Sigmoid activation function or a hyperbolic tangent activation function.
Further, the working process of the quantum long-time and short-time memory neural network is as follows:
the method comprises the steps of taking the output of an Input layer as the Input of a QLSTM layer, and dividing the feature extraction of the QLSTM layer into two processes, wherein the first process is the forward propagation feature extraction among QLSTM units, the second process is the backward propagation feature extraction among the QLSTM units, connecting the output of the last QLSTM unit in two directions, taking the connection result as the final output of the QLSTM layer, taking the output of the QLSTM layer as the Input of a full connection layer, mapping the feature to a [0, 1] interval through a Sigmoid activation function, taking the mapping result as the probability of social text emotion polarity, and if the probability P is more than or equal to 0.5, the social text expression emotion is positive, and otherwise, the expressed emotion is negative.
Further, when the quantum long-time and short-time memory neural network is pre-trained, the adopted loss function is a cross entropy loss function, and the adopted network parameter updating method is an RMSprop algorithm.
Further, the method adopted by the network convergence module is a bagging algorithm.
Further, the VQC cell body structurally comprises a quantum coding layer, a variation circuit layer and a quantum measuring layer;
the quantum operation of the variational circuit layer comprises a multi-qubit Toffoli gate and a single-qubit revolving gate, wherein the multi-qubit Toffoli gate is used for replacing a cnot quantum gate, and the multi-qubit Toffoli gate is used for quantum entanglement of three quantum wires.
Further, the text sequence information acquisition model is a bert pre-training model.
The invention has the beneficial effects that:
the invention provides an adjustable parameter sub-deep learning method for social text sentiment analysis, the used quantum computation only needs to store input and output without storing intermediate results, so that the storage space of binary codes is saved, the problem of high storage cost of the binary codes is solved, and the quantum parallel computation does not need to gradually compute the classical computation of each deep neural network, so that the time complexity of the deep neural networks is reduced. The method can obtain a better model by adopting staged training, and has higher prediction precision and stronger robustness compared with the prior method.
Meanwhile, the invention utilizes quantum entanglement and quantum probability to calculate, enlarges the expression space, has high training operation speed and is easy to realize.
Drawings
FIG. 1 is a flow chart of the method of the present invention;
FIG. 2 is a diagram of an initial model architecture for emotion analysis, according to an embodiment;
FIG. 3 is a schematic diagram of a cell body structure of a quantum long-short time memory neural network in an embodiment;
FIG. 4 is a schematic diagram of a general structure of VQC in the embodiment;
FIG. 5 is a schematic diagram of the principle of quantum encoding in an example;
FIG. 6 is a schematic diagram of VQC structure of QLSTM in the example;
FIG. 7 is a schematic diagram of a quantum long-short term memory neural network model training flow of an embodiment;
FIG. 8 is a schematic diagram of a model structure of a quantum long-and-short time memory neural network in the embodiment;
FIG. 9 is a diagram of neural network training in an example.
Detailed Description
First embodiment this embodiment will be described with reference to fig. 1. The social text sentiment analysis system based on the deep quantum neural network comprises a data acquisition module, a data processing module, a text sequence information acquisition model and a sentiment analysis model, wherein:
the data acquisition module is used for acquiring an emotion classification data set, and the emotion classification data set comprises comment texts and labels corresponding to the comment texts;
the label is an emotion label, and the emotion label comprises: comments on positive emotional tendency and comments on negative emotional tendency;
the data processing module is used for segmenting the comment texts in the acquired emotion classification data set to obtain a comment text word sequence, and then mapping the comment text word sequence into a word vector space to obtain vectorized text sequence information;
the text sequence information acquisition model is trained by utilizing the comment text word sequence obtained by the data processing module and the corresponding vectorized text sequence information, and the output of the trained text sequence information acquisition model is vectorized text sequence information;
the emotion analysis model comprises a quantum long-time and short-time memory neural network and a network fusion module, wherein the quantum long-time and short-time memory neural network comprises an Input layer, a QLSTM layer and a full connection layer, and the QLSTM layer comprises t QLSTM units;
the quantum long-short term memory neural network utilizes vectorization text sequence information and labels corresponding to data in the emotion classification data set to pre-train, after n pre-trained quantum long-short term memory neural networks are obtained, the network fusion module fuses the n pre-trained quantum long-short term memory neural networks, and the output of the fused quantum long-short term memory neural networks is used as the output of the emotion analysis model;
when the neural network is memorized in a pre-training quantum long-term manner, in order to facilitate network convergence, a sample needs to be standardized and adjusted to a [0, 1] interval, specifically as follows:
Figure RE-GDA0003510186100000051
in the formula, xmaxAnd xminMaximum and minimum values in known sample data; x is the number ofjSample data which needs to be adjusted currently;
after the comment text to be analyzed is segmented, obtaining a comment text word sequence to be analyzed; inputting a comment text word sequence to be analyzed into a trained text sequence information acquisition model, and acquiring vectorized text sequence information corresponding to the comment text to be analyzed;
and inputting the vectorized text sequence information corresponding to the comment text to be analyzed into the pre-trained and fine-tuned emotion analysis model, and outputting the emotion analysis result of the comment text to be analyzed.
The second embodiment is as follows: the difference between the embodiment and the specific embodiment is that the data acquired by the data acquisition module further includes a target data set, and the data format of the target data set is the same as that of the emotion classification data set, that is, the target data set includes a comment text and a tag corresponding to the comment text;
and fine-tuning the pre-trained emotion analysis model by utilizing vectorization text sequence information corresponding to the comment text in the target data set and the label to obtain a final emotion analysis model.
Other steps and parameters are the same as those in the first embodiment.
The third concrete implementation mode: the difference between the first embodiment and the second embodiment is that the emotion classification data set is obtained by crawling on a new wave, and a Scapy distributed crawler frame is adopted in the crawling mode;
the target data set is a data set which is organized and published from hotel comments of the journey network in 2018.
Other steps and parameters are the same as those in the first or second embodiment.
The fourth concrete implementation mode: this embodiment differs from one of the first to third embodiments in that the QLSTM unit is defined as:
vt=ht-1*xt
ft=Activate(VQC1(vt))
it=Activate(VQC2(vt))
Figure RE-GDA0003510186100000052
Figure RE-GDA0003510186100000061
ot=Activate(VQC4(vt))
ht=VQC5(ot*Activate(ct))
yt=VQC6(ot*Activate(ct))
wherein x istIs the input vector at time t of the QLSTM cell, ht-1Is a hidden state at time t-1, vtIs an input vector of VQC cell body time t, Activate (r) is an activation function, ftForgetting gate vector, i, at time ttFor the input gate vector at time t,
Figure RE-GDA0003510186100000062
temporary cell state at time t, ct-1The cell state at time t-1, ctThe cell state at time t, otIs the output gate vector at time t, htHidden state at time t, ytFor the output state at time t, VQC1、VQC2、VQC3、VQC4、VQC5、VQC6Respectively represent the 1 st, 2 nd, 3 rd, 4 th, 5 th and 6 th VQC cell bodies.
Other steps and parameters are the same as those in one of the first to third embodiments.
The fifth concrete implementation mode: the difference between this embodiment and one of the first to fourth embodiments is that the activation function Activate is a Sigmoid activation function or a hyperbolic tangent activation function.
Other steps and parameters are the same as in one of the first to fourth embodiments.
The sixth specific implementation mode: the difference between this embodiment and one of the first to fifth embodiments is that the working process of the quantum long-time and short-time memory neural network is as follows:
the output of an Input layer is used as the Input of a QLSTM layer, the feature extraction of the QLSTM layer is divided into two processes, wherein the first process is the forward propagation feature extraction among QLSTM units, the second process is the backward propagation feature extraction among the QLSTM units, the output of the last QLSTM unit in two directions is connected, the connection result is used as the final output of the QLSTM layer, the output of the QLSTM layer is used as the Input of a full connection layer, after the features are mapped to a [0, 1] interval through a Sigmoid activation function, the mapping result is used as the probability of social text emotion polarity, if the probability P is larger than or equal to 0.5, the social text expression emotion is positive, and otherwise, the expressed emotion is negative.
The unidirectional network only stores past information, ignores future information, and can only predict a prediction result according to the past information; unlike the unidirectional neural network, the bidirectional neural network in the embodiment stores past and future information, and combines the two information as two hidden states, so that a prediction result can be presumed according to the past and future information, and the accuracy of prediction is improved.
Other steps and parameters are the same as those in one of the first to fifth embodiments.
The seventh concrete implementation mode: the difference between this embodiment and one of the first to sixth embodiments is that, when the quantum long-and-short-term memory neural network is pre-trained, the adopted loss function is a cross entropy loss function, and the adopted network parameter updating method is an RMSprop algorithm.
Adjusting parameters of the quantum long-time and short-time memory neural network model through an iterative training model to obtain an optimal neural network model:
the parameters of the quantum neural network model are mainly adjustable parameter quantum gates, such as single quantum bit revolving gate RIWhich needs to learn αI,βIAnd gammaIThese three parameters; when the output of the network is not equal to the expected value, an error function exists, and the error is propagated reversely to adjust the parameters of the adjustable parameter sub-gate to train the quantum length memory neural network.
In the optimization process, a parameter offset method is used toAn analytical gradient of the quantum circuit is obtained. Given an observation
Figure RE-GDA0003510186100000071
Desired value of (a):
Figure RE-GDA0003510186100000072
where x is the input value of the quantum circuit, U0(x) Preparing conventional x to quantum state code, i is the index of circuit parameter to calculate gradient, Uii) Is a Pauli matrix generated by rotation of a single quantum bit, f relative to a parameter θiThe gradient of (a) is:
Figure RE-GDA0003510186100000073
the analysis evaluation expected parameter theta can be obtainediAnd applying gradient descent optimization from classical machine learning to a VQC-based machine learning model.
Wherein the parameter migration method is to express the gradient as a linear combination of evaluation functions at two different points, and the evaluation expectation is that f is relative to the parameter thetaiOf the gradient of (c).
Other steps and parameters are the same as those in one of the first to sixth embodiments.
The specific implementation mode is eight: the difference between this embodiment and one of the first to seventh embodiments is that the method adopted by the network convergence module is a bagging algorithm.
And combining the quantum long-time and short-time memory neural networks trained by different data sets into a strong learner by a voting method to improve the robustness of the model. The self-service sampling method of the bagging algorithm can effectively avoid overfitting, and the generalization performance is improved through the increase of the difference degree between individual networks; the method can process high-dimensional features without feature selection; the training device is simple in structure, easy to implement, low in calculation overhead and high in training efficiency.
Other steps and parameters are the same as those in one of the first to seventh embodiments.
The specific implementation method nine: the difference between the present embodiment and one of the first to eighth embodiments is that the structure of the VQC cell body includes a quantum encoding layer, a variational circuit layer, and a quantum measuring layer;
the quantum operation of the variation circuit layer comprises a multi-qubit Toffoli gate and a single-qubit revolving gate, wherein the multi-qubit Toffoli gate is used for replacing a cnot quantum gate, and the multi-qubit Toffoli gate is used for quantum entanglement of three quantum lines.
The VQC cell body is a quantum circuit with adjustable parameters and can be subjected to iterative optimization. The principle is to encode classical data into quantum state and send it into quantum circuit, and transform it by quantum gate with adjustable parameters. And finally, measuring the result of the converted result by using a quantum measurer.
A quantum measurement layer that takes into account the expected value of each qubit by measurement on a computational basis. Using a quantum simulation platform, numerical calculations can be performed on classical computers, whereas on real quantum computers, these values are statistically estimated by repeated measurements, which should theoretically be close to the simulated values at the zero noise limit. The result returned is a fixed-length vector that will be further processed on a classical computer.
The CNOT quantum gate can only consider the relationship between two adjacent quantum lines, and the state of the former line determines whether the latter line performs Not operation, which is often insufficient; the Toffoli gate can consider the relation of three quantum lines, and the states of the first two lines determine whether the last line is subjected to Not operation, so that more bases can be provided for the prediction result, and the generated effect is better.
Other steps and parameters are the same as those in one to eight of the embodiments.
The detailed implementation mode is ten: the difference between this embodiment and one of the first to ninth embodiments is that the text sequence information acquisition model is a bert pre-training model.
Other steps and parameters are the same as in one of the first to tenth embodiments.
The invention will be further explained with reference to the following drawings and examples, in particular:
as shown in fig. 1, the present embodiment provides a social text sentiment analysis method based on a quantum long-and-short-term memory neural network, including the following steps:
s201, obtaining an emotion classification data set and a target data set.
In this step, obtaining an emotion analysis data set specifically includes:
and crawling comment texts and labels from the new waves in a large scale. Specifically, crawlers are used to crawl comment texts from newwave posts, and a Scapy distributed crawler frame is used in the crawling mode. One text comment corresponds to one comment tag for representation, and is stored in a binary format, so that an emotion analysis data set is obtained.
The target data set adopts a data set which is sorted and disclosed by hotel comments of the cellular network in 2018, the positive and negative samples in the target data set are utilized, the used data format is the same as that of the emotion analysis data set, and the data set is smaller than the emotion analysis data set.
S202, constructing an emotion analysis initial model.
In step 202, as shown in fig. 2, an emotion analysis initial model is built mainly for constructing a quantum long-short time memory neural network and model fusion.
The quantum long-short time memory neural network specifically comprises the following components: in order to extract emotional features related to social text context, a bidirectional quantum long-short term memory neural network is constructed and comprises an Input layer, a QLSTM layer and a full connection layer, wherein the QLSTM layer comprises t QLSTM units, and the QLSTM units are connected in a parallel and opposite mode and used for extracting emotional features related to social text context.
The QLSTM unit adopts the cell body structure of the quantum long-time memory neural network shown in the figure 3. It consists of 6 VQC structures and classical binary gates. The QLSTM cell is defined here as (the Activate block represents the laser)And the active function can be selected from a Sigmoid active function and a hyperbolic tangent active function. x is the number oftIs the input vector at time t of the QLSTM cell, htIs a hidden state at time t, vtIs the input direction of VQC cell body at time t, ctIs the cell state at time t):
vt=ht-1*xt (1)
ft=Sigmoid(VQC1(vt)) (2)
it=Sigmoid(VQC2(vt)) (3)
Figure RE-GDA0003510186100000091
Figure RE-GDA0003510186100000092
ot=Sigmoid(VQC4(vt)) (6)
ht=VQC5(ot*tanh(ct)) (7)
yt=VQC6(ot*tanh(ct)) (8)
wherein, the expression (1) is the hidden state ht-1And the input vector x of the QLSTM celltMultiplying to obtain an input vector v of VQC cell body time tt
Wherein, the formula (2) realizes the function of forgetting the door. Using a VQC1Input v at cell body detection time ttOutputting a value of [0, 1] through an activation function Sigmoid]Forgetting gate vector f in intervalt。ftBy acting at ct-1(i.e. f)t*ct-1) The determination of the "forgotten" or "retained" cell state c by a gating mechanismt-1
Wherein, the formula (3) realizes the function of the input gate. Using a VQC2Input v at cell body detection time ttOutput by activating function SigmoidA value of [0, 1]Input gate vector i within a spant. The formula (4) generates a temporary transition state
Figure RE-GDA0003510186100000101
Using VQC3From input vtAnd the activation function tanh to generate a temporary cell state
Figure RE-GDA0003510186100000102
Finally, equation (5) will be input into gate itMultiplication by temporary cell status
Figure RE-GDA0003510186100000103
Re-association with cell status ct-1Sum vector ftThe result of the multiplication is summed up with the cell state c at the update time tt
Wherein, the formula (6), the formula (7) and the formula (8) realize the output function. The formula (6) utilizes a VQC4Input v at cell body detection time ttOutputting a value of [0, 1] through an activation function Sigmoid]Output gate vector o within intervalt. The formula (7) generates the hidden state htUsing VQC5Vector o through the output gatetAnd the cell state c of the activation function tanhtGenerating a hidden state ht. The formula (8) generates the output state ytUsing VQC6Vector o through the output gatetAnd the cell state c of the activation function tanhtGenerating an output state yt
The VQC structure is shown in FIG. 4 and comprises a quantum coding layer U (x), a variation circuit layer V (theta) and a quantum measurement layer. (x is the classical data requiring input quantum wire processing; theta is the angle at which quantum data requires rotation)
The principle of quantum encoding is shown in fig. 5, and the quantum state of N qubits can be expressed as:
Figure RE-GDA0003510186100000104
wherein
Figure RE-GDA0003510186100000105
Is each ground state and each qiE {0,1 }. Amplitude of vibration
Figure RE-GDA0003510186100000106
Is squared of
Figure RE-GDA0003510186100000107
The measured probability of the post-intermediate state, such that the total probability equals 1:
Figure RE-GDA0003510186100000108
according to the quantum coding principle, a schematic diagram of a specific structure of the VQC designed herein is shown in FIG. 6. The quantum-encoding layer U (x) comprising H, RyAnd RzAnd a door. The variational circuit layer V (theta) comprises Toffoli gate and RIThe door is composed of a door body. The quantum measurement layer measures the output of the quantum wires by the monte carlo method through the measurement gate.
Figure RE-GDA0003510186100000109
Figure RE-GDA00035101861000001010
Figure RE-GDA00035101861000001011
RI=R(αIII)=exp(-i(αIII)θ/2)=cos(θ/2)-isin(θ/2)(αIII)
xt+1=RI(xt)
Wherein x istIs the classical data quantum state at time t; h door is reversible single quantityA sub-gate, which can rapidly prepare uniformly superposed qubits; ry、RzAnd RIThe door belongs to a rotating single quantum door, and can enable the input state to rotate for a certain angle around a corresponding shaft; toffoli gate belongs to the gate of control bit, only if the control bit is all |1>The state of the controlled bit is exchanged; i is the unit of imaginary numbers in mathematics; i is the I-th quantum wire; theta refers to the angle of rotation on a certain axis; alpha is alphaIII3 rotation angles on the x, y, z axes, respectively.
The Monte Carlo method is a numerical simulation method which takes a probability phenomenon as a research object.
Wherein, the model fusion is specifically as follows: and combining the quantum long-time and short-time memory neural networks trained by different data sets into a strong learner by a voting method.
S203, vectorizing the comment text sequence of the emotion classification data set, and performing word vector model training on the vectorized comment text sequence to obtain a vectorized comment text sequence.
In the step S203, a participler is adopted to perform participle on the comment text, the comment text sequence of the emotion data set is mapped into a word vector space, and the length of vectorization of the comment text is calculated.
In this step, S203 pre-trains the comment text vector using the pre-training model, and inputs the segmented comment text sequence and the length thereof into the pre-training model, so that vectorized text sequence information is output.
And S204, inputting the pre-trained text sequence and the label into an emotion analysis initial model for training to obtain an emotion analysis pre-training model.
In step S204, the pre-trained text sequence and the label are input into the emotion analysis initial model for training, as shown in fig. 7, specifically as follows:
and (3) carrying out training set and verification set processing on the text sequence and the comment labels trained by the word vector model, and carrying out comparison between 4: the 1 proportion is randomly divided into a training set and a testing set, so that overfitting caused by too small data volume in the model training process is avoided. As shown in fig. 8, a training set represented by m n × d dimensional matrices is Input into a QLSTM layer from an Input layer, the feature extraction of the QLSTM layer is divided into two processes, the first process is forward propagation [ QLSTM (f)) ] feature extraction between QLSTM units, the second process is backward propagation [ QLSTM (b)) ] feature extraction between QLSTM units, and finally, the output of the last QLSTM unit in two directions is connected as the final output of the QLSTM layer, and the calculation formulas of forward propagation and backward propagation QLSTM are as follows:
Figure RE-GDA0003510186100000111
Figure RE-GDA0003510186100000112
wherein c istIndicating the cell state, h, of QLSTM at time ttIndicating the hidden state at time t, xtFor input at time t, ct-1、ht-1And ct+1、ht+1Representing the state of the unit and the hidden state at the last moment, the parameters of the QLSTM in the two directions are shared, and the output of the QLSTM layer is finally represented as the output connection result of the last QLSTM unit in the two directions, wherein n is the length of the social text sequence.
And inputting the output of the QLSTM layer into a full-connection layer for feature dimension reduction, and mapping the features into a [0, 1] interval through a Sigmoid activation function, namely the probability of social text emotion polarity. If the probability P is more than or equal to 0.5, the emotion expressed by the social text is positive, otherwise, the expressed emotion is negative.
Adjusting model parameters of the quantum long-time and short-time memory neural network, specifically: and (4) training the quantum long-time and short-time memory neural network in the step (S202) by combining with training data. Model training adopts a cross entropy function to calculate model prediction and label loss; the model training adopts RMSprop algorithm to update parameters of each layer of the network, and the updating formula is as follows:
Figure RE-GDA0003510186100000121
Figure RE-GDA0003510186100000124
Figure RE-GDA0003510186100000122
wherein l [ i ]]Is the label of sample i, o [ i]Probability predicted for sample i, gtGradient of step t, E [ g ]2]tIs the sum of squares of the gradients
Figure RE-GDA0003510186100000123
Weighted moving average of (3). For QLSTM, the hyper-parameters are set as follows: learning rate η is 0.01, smoothing constant α is 0.99, and e is 10-8
And (4) adjusting quantum gate parameters of the quantum long-time and short-time memory neural network through calculation, and carrying out next neural network training.
Carrying out iterative training on the quantum long-time memory neural network, specifically comprising the following steps: training the model to converge when 10 iterations are performed, and taking the model at the moment as a feature extraction model; and extracting social text features by using the trained quantum long-short term memory neural network model, thereby obtaining the neural network training process of the graph 9. Since n quantum long-time and short-time memory neural network models with better performance need to be trained in step S202, n times of neural network training need to be traversed. These models are fused by voting to form a strong learner.
S205, performing fine tuning training on the target data set by using the emotion analysis pre-training model to obtain an emotion analysis model.
Specifically, parameters learned by the emotion analysis pre-training model are migrated and verified on a target data set, so that fusion is performed depending on a plurality of quantum long-time and short-time memory neural networks. If the effect is not good, the quantum long-short time memory neural network model parameters of the S204 need to be retrained and optimized, so that n quantum long-short time memory neural networks are obtained again for model fusion. Then, the target data set is used for testing.
And S206, performing word segmentation and word vector model training on the analysis text, and finally inputting an emotion analysis model for emotion analysis.
The public opinion emotional tendency can be predicted efficiently within a certain speed, so that social media comments are guided to develop in the correct direction.
The above-described calculation examples of the present invention are merely to explain the calculation model and the calculation flow of the present invention in detail, and are not intended to limit the embodiments of the present invention. It will be apparent to those skilled in the art that other variations and modifications of the present invention can be made based on the above description, and it is not intended to be exhaustive or to limit the invention to the precise form disclosed, and all such modifications and variations are possible and contemplated as falling within the scope of the invention.

Claims (10)

1. A social text sentiment analysis system based on a deep quantum neural network is characterized by comprising a data acquisition module, a data processing module, a text sequence information acquisition model and a sentiment analysis model, wherein:
the data acquisition module is used for acquiring an emotion classification data set, and the emotion classification data set comprises comment texts and labels corresponding to the comment texts;
the data processing module is used for segmenting the comment texts in the acquired emotion classification data set to obtain a comment text word sequence, and then mapping the comment text word sequence into a word vector space to obtain vectorized text sequence information;
the text sequence information acquisition model is trained by utilizing the comment text word sequence obtained by the data processing module and the corresponding vectorized text sequence information, and the output of the trained text sequence information acquisition model is vectorized text sequence information;
the emotion analysis model comprises a quantum long-time and short-time memory neural network and a network fusion module, wherein the quantum long-time and short-time memory neural network comprises an Input layer, a QLSTM layer and a full connection layer, and the QLSTM layer comprises t QLSTM units;
the quantum long-short term memory neural network utilizes vectorization text sequence information and labels corresponding to data in the emotion classification data set to pre-train, after n pre-trained quantum long-short term memory neural networks are obtained, the network fusion module fuses the n pre-trained quantum long-short term memory neural networks, and the output of the fused quantum long-short term memory neural networks is used as the output of the emotion analysis model;
after the comment text to be analyzed is segmented, obtaining a comment text word sequence to be analyzed; inputting a comment text word sequence to be analyzed into a trained text sequence information acquisition model, and acquiring vectorized text sequence information corresponding to the comment text to be analyzed;
and inputting the vectorized text sequence information corresponding to the comment text to be analyzed into an emotion analysis model, and outputting an emotion analysis result of the comment text to be analyzed.
2. The social text sentiment analysis system based on the deep quantum neural network is characterized in that the data acquired by the data acquisition module further comprises a target data set, the data format of the target data set is the same as that of the sentiment classification data set, namely the target data set comprises comment texts and labels corresponding to the comment texts;
and fine-tuning the pre-trained emotion analysis model by utilizing vectorization text sequence information corresponding to the comment text in the target data set and the label to obtain a final emotion analysis model.
3. The social text sentiment analysis system based on the deep quantum neural network is characterized in that the sentiment classification data sets are obtained by crawling on the new waves in a Scapy distributed crawler frame;
the target data set is a data set which is sorted and published from hotel comments of the cellular network in 2018.
4. The deep quantum neural network-based social text sentiment analysis system of claim 3, wherein the QLSTM units are defined as:
vt=ht-1*xt
ft=Activate(VQC1(vt))
it=Activate(VQC2(vt))
Figure FDA0003355613100000021
Figure FDA0003355613100000022
ot=Activate(VQC4(vt))
ht=VQC5(ot*Activate(ct))
yt=VQC6(ot*Activate(ct))
wherein x istIs the input vector at time t of the QLSTM cell, ht-1Is a hidden state at time t-1, vtIs an input vector of VQC cell body time t, Activate (r) is an activation function, ftForgetting gate vector, i, at time ttFor the input gate vector at time t,
Figure FDA0003355613100000023
temporary cell state at time t, ct-1The cell state at time t-1, ctThe cell state at time t, otIs the output gate vector at time t, htHidden state at time t, ytFor the output state at time t, VQC1、VQC2、VQC3、VQC4、VQC5、VQC6Are respectively provided withRepresents the 1 st, 2 nd, 3 rd, 4 th, 5 th and 6 th VQC cell bodies.
5. The social text sentiment analysis system based on the deep quantum neural network of claim 4, wherein the activation function Activate is a Sigmoid activation function or a hyperbolic tangent activation function.
6. The social text sentiment analysis system based on the deep quantum neural network as claimed in claim 5, wherein the working process of the quantum long-time and short-time memory neural network is as follows:
the output of an Input layer is used as the Input of a QLSTM layer, the feature extraction of the QLSTM layer is divided into two processes, wherein the first process is the forward propagation feature extraction among QLSTM units, the second process is the backward propagation feature extraction among the QLSTM units, the output of the last QLSTM unit in two directions is connected, the connection result is used as the final output of the QLSTM layer, the output of the QLSTM layer is used as the Input of a full connection layer, after the features are mapped to a [0, 1] interval through a Sigmoid activation function, the mapping result is used as the probability of social text emotion polarity, if the probability P is larger than or equal to 0.5, the social text expression emotion is positive, and otherwise, the expressed emotion is negative.
7. The social text sentiment analysis system based on the deep quantum neural network as claimed in claim 6, wherein when the quantum long-time memory neural network is pre-trained, the adopted loss function is a cross entropy loss function, and the adopted network parameter updating method is an RMSprop algorithm.
8. The social text sentiment analysis system based on the deep quantum neural network of claim 7, wherein the method adopted by the network fusion module is a bagging algorithm.
9. The deep quantum neural network-based social text sentiment analysis system according to claim 8, wherein the structure of the VQC cell bodies comprises a quantum coding layer, a variation circuit layer and a quantum measurement layer;
the quantum operation of the variational circuit layer comprises a multi-qubit Toffoli gate and a single-qubit revolving gate, wherein the multi-qubit Toffoli gate is used for replacing a cnot quantum gate, and the multi-qubit Toffoli gate is used for quantum entanglement of three quantum wires.
10. The deep quantum neural network-based social text sentiment analysis system of claim 9, wherein the text sequence information acquisition model is a bert pre-training model.
CN202111350644.XA 2021-11-15 2021-11-15 Social text sentiment analysis system based on deep quantum neural network Pending CN114461791A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111350644.XA CN114461791A (en) 2021-11-15 2021-11-15 Social text sentiment analysis system based on deep quantum neural network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111350644.XA CN114461791A (en) 2021-11-15 2021-11-15 Social text sentiment analysis system based on deep quantum neural network

Publications (1)

Publication Number Publication Date
CN114461791A true CN114461791A (en) 2022-05-10

Family

ID=81405938

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111350644.XA Pending CN114461791A (en) 2021-11-15 2021-11-15 Social text sentiment analysis system based on deep quantum neural network

Country Status (1)

Country Link
CN (1) CN114461791A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115130655A (en) * 2022-05-22 2022-09-30 上海图灵智算量子科技有限公司 Method for solving product reaction center prediction in inverse synthesis
CN116992942A (en) * 2023-09-26 2023-11-03 苏州元脑智能科技有限公司 Natural language model optimization method, device, natural language model, equipment and medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115130655A (en) * 2022-05-22 2022-09-30 上海图灵智算量子科技有限公司 Method for solving product reaction center prediction in inverse synthesis
CN116992942A (en) * 2023-09-26 2023-11-03 苏州元脑智能科技有限公司 Natural language model optimization method, device, natural language model, equipment and medium
CN116992942B (en) * 2023-09-26 2024-02-02 苏州元脑智能科技有限公司 Natural language model optimization method, device, natural language model, equipment and medium

Similar Documents

Publication Publication Date Title
CN109492822B (en) Air pollutant concentration time-space domain correlation prediction method
CN109284506B (en) User comment emotion analysis system and method based on attention convolution neural network
Shen et al. Wind speed prediction of unmanned sailboat based on CNN and LSTM hybrid neural network
CN106156003B (en) A kind of question sentence understanding method in question answering system
CN111860982A (en) Wind power plant short-term wind power prediction method based on VMD-FCM-GRU
CN109829541A (en) Deep neural network incremental training method and system based on learning automaton
CN114461791A (en) Social text sentiment analysis system based on deep quantum neural network
CN111222992A (en) Stock price prediction method of long-short term memory neural network based on attention mechanism
Wu et al. Optimized deep learning framework for water distribution data-driven modeling
Pavlov et al. Machine learning and the Schrödinger equation
CN110019796A (en) A kind of user version information analysis method and device
CN116543289B (en) Image description method based on encoder-decoder and Bi-LSTM attention model
Feng et al. A dual-staged attention based conversion-gated long short term memory for multivariable time series prediction
CN116579408A (en) Model pruning method and system based on redundancy of model structure
Miao Emotion Analysis and Opinion Monitoring of Social Network Users Under Deep Convolutional Neural Network
Shen et al. Online teaching course recommendation based on autoencoder
CN115759343A (en) E-LSTM-based user electric quantity prediction method and device
CN115063972A (en) Traffic speed prediction method and system based on graph convolution and gate control cyclic unit
CN110852505B (en) Smart city traffic flow prediction method based on quantum genetic optimization LVQ neural network
Jiang et al. Deep belief improved bidirectional LSTM for multivariate time series forecasting
Zuhri et al. Probability Prediction for Graduate Admission Using CNN-LSTM Hybrid Algorithm
Mandhasiya et al. Evaluation of Machine Learning Performance Based on BERT Data Representation with LSTM Model to Conduct Sentiment Analysis in Indonesian for Predicting Voices of Social Media Users in the 2024 Indonesia Presidential Election
Yun et al. Quality evaluation and satisfaction analysis of online learning of college students based on artificial intelligence
Bai AGA-LSTM: An Optimized LSTM Neural Network Model Based on Adaptive Genetic Algorithm
Wang An Evaluation Method of English Composition Automatic Grading Based on Genetic Optimization Algorithm and CNN Model

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination