Full text
BOOKSPINE ii SentimentClassificationUsingTree‐BasedGated RecurrentUnits VasileiosTsakalos Dissertationpresentedaspartialrequirementforobtaining theMaster’sdegreeinInformationManagement
Sentiment Classification Using Tree-Based Gated Recurrent Units Copyright © Vasileios Tsakalos, NOVA Information Management School, NOVA University of Lisbon. The NOVA Information Management School and the NOVA University of Lisbon have the right, perpetual and without geographical boundaries, to file and publish this dissertation through printed copies reproduced on paper or on digital form, or by any other means known or that may be invented, and to disseminate through scientific repositories and admit its copying and distribution for non-commercial, educational or research purposes, as long as credit is given to the author and editor. This document was created using the (pdf)L A T EX processor, based in the “novathesis” template[1], developed at the Dep. Informática of FCT-NOVA [2]. [1] https://github.com/joaomlourenco/novathesis [2] http://www.di.fct.unl.pt
Acknowledgements I would like to thank my supervisor professor, Dr. Roberto Henriques, for helping me structure the report, advising me with regards to the mathematically complexity required. Moreover I would like to thank my brother, Evangelos Tsakalos, for providing me with the computational power to run the experiments and advising me regarding the subject of my master thesis. v
Abstract Natural Language Processing is one of the most challenging fields of Artificial Intelligence. The past 10 years, this field has witnessed a fascinating progress due to Deep Learning. Despite that, we haven’t achieved to build an architecture of models that can understand natural language as humans do. Many architectures have been proposed, each of them having its own strengths and weaknesses. In this report, we will cover the tree based architectures and in particular we will propose a different tree based architecture that is very similar to the Tree-Based LSTM, proposed by Tai(2015). In this work, we aim to make a critical comparison between the proposed architecture - Tree-Based GRU - with Tree-based LSTM for sentiment classification tasks, both binary and fine-grained. Keywords: Deep Learning, Natural Language Processing, Recursive Neural Networks, Sentiment Classification vii
Resumo ix
Chapter 1 Introduction 1.1 Motivation This paper aims to contribute to the Artificial Intelligence community by proposing a different architecture(Tree-based GRU 3.2.6) and presenting its results in comparison to Tree-Based LSTM [77](3.2.5). The conduction of this experiment is done as GRU architecture is less complicated and has less parameters to compute than LSTM. Therefore, we hypothesize that it is faster to train. GRU is a new approach, it is not determined whether it is better than LSTM or not [10], so far it is assumed that the comparison between those two models is like a comparison betweem non-linear activation functions, there is no "best"function but some non-linearities suit better some problems. 1.2 Overview of Thesis This thesis consists of 5 chapters. The first chapter, the introduction, provides the reader with the necessary background to be able to read this report. The second chapter(2), word embeddings, is about the representation of the words on the vector space. On the second chapter we will go through the word embeddings benefits and the most efficient algorithms that are used to achieve this transformation (from words, to vectors). It is important for the reader to be aware of the fact that word embeddings are the input for the Tree-based GRU (and every other language model that we cover in this report). The third chapter(3), feedback neural networks, makes an in depth commentary of the feedback neural networks and its most common architectures. The forth chapter(4), network training, goes through the gradient descent algorithm, its different variants and extensions but also covers the properties of the neural network’s 1
CHAPTER 1. INTRODUCTION hyperparameters. Finally, the fifth chapter(5), experiments, demonstrates the comparison between Tree-based GRU and Tree-based LSTM, it also describes the gradient descent variants and the hyperparameters that were selected for the training of the model. 1.3 Background This section provides the essential background on sentiment classification, sequences, syntactic structures, and neural networks. 1.3.1 Sentiment Classification and Sequences Sentiment analysis/classification [59] (also known as opinion mining) is the classification on whether a piece of text is positive, negative or neutral using NLP, statistics, or machine learning methods. A sequence is a string of objects. Each sequence is a row of item sets.The individual elements in a sequence are also called terms. In the case of the word sequences, a word corresponds to an item. In the case of the health care data, a test value is an item. Treating data as sequential (when they are sequences) improve the prediction accuracy of the classifiers [50]. 1.3.2 Syntactic Structure The sentences can be described with two ways for a machine to make sense out of them, the first one is by breaking up the sentence to phrases(constituents), which is known as constituent structure, and the second is by connecting the words with links, which is known as dependency structure. Those structures are constructed by parsing algorithms. The parsers for constructing a constituent tree are called phrase structured parsers and the parsers for dependency structures are called dependency parsers. 1.3.2.1 Constituency Structure The phrase structure was introduced by Noam Chomsky, the idea behind constituency phrase structure is to organize the words into nested constituents[58] [46](Figure 1.1). Meaning that each nested constituent (word phrase) is a word unit. There has been different criteria for determining the constituents. The most popular is the one that claims that a constituent behaves as a unit no matter the place that is located in the sentence. Regarding to the construction of this structure, one great parser is the constituent parser from Zhu[83]. 2
1.3. BACKGROUND Figure 1.1: Constituency Tree Source :“A Generative Constituent-Context Model for Improved Grammar Induction.”, D.Klein, 2002 1.3.2.2 Dependency Structure The idea behind dependency structure is having words connected with a dependency relation (Figure 1.2),where one of them is the head and the other is the dependent and there is a link connecting them. In more detail, the dependent is the modifier, object, or complement while the head determines the behavior of the pair. The dependent requires the presence of the head; the head on the other hand doesn’t require the presence of the dependent. [17]. In general, the dependency structure is a tree with the main verb as its root (head of the whole structure). It is worth mentioning that a dependency structure can be constructed from constituent trees as well [19]. The idea behind dependency structure is to directly show for the words of a sentence which are the words depend on (modify or are arguments of) which other words. [45] Figure 1.2: Dependency Tree Source :“A Generative Constituent-Context Model for Improved Grammar Induction.”, D.Klein, 2002 1.3.3 Neural Networks Neural networks are models of computation that were inspired by the way (we assume) our brain works [52], [65],[66]. The structure of artificial neural networks (ANN) is a network of small processing units (neurons) that are connected with weighted joints. Over the years many variants of ANN has been proposed. One important distinction is the way they are connected,with cycles or without. The former case of neural networks 3
CHAPTER 1. INTRODUCTION are called feedback or recursive neural networks and will be examined at chapter 3, the latter case of neural networks are the Feedforward networks that will be examined at the next subsection. 1.3.3.1 Feedforward Networks Given the absence of cycles, all nodes can be arranged into layers, and the outputs in each layer can be calculated given the outputs from the lower layers. The input i to a feedforward network is provided by setting the values of the lowest layer. Each higher layer is then successively computed until output is generated at the output layer o (Figure 1.3). Figure 1.3: Feed-forward neural network Source : https://www.linkedin.com/pulse/learning-scale-end-then-logic-ishtiaq-rahman Let wl jk be the weight for the connection from the kth neuron in the layer l − 1 to the jth neuron in the lth layer, bl j the bias of node j at layer l and αl j for the activation of neuron jat lth layer. The equation below is using the sigmoid function. αl j=σ(X limit=k wl jkαl−1 k+bl j) (1.1) Having the equation above in mind, we can rewrite it in a more compact and vectorized form: αl=σ(wlαl−1+bl) (1.2) Let zl=Plimit=kwl jkαl−1 k+bl jbe the weighted input to the neurons in layer l. αl=σ(zl) (1.3) The most popular choices of activation function are the hyperbolic tangent (1.4), sigmoid (1.5), rectified linear unit(1.6), softmax (generalization of sigmoid for K classes)(1.7) . 4
1.3. BACKGROUND tanh(x) = e2x1 e2x+ 1 (1.4) σ(x) = 1 1 + ex(1.5) f(x) = max(0,x) (1.6) sof tmax(x)j=exj K X k=1 exk ,f orj = 1,....,K (1.7) The most popular FNNs are perceptrons[65], Kohonen maps[63] and Hopfield nets[41] and multilayer perceptron (MLP)[66],[80], [6]. 1.3.3.2 Backpropagation The most successful algorithm for training neural networks is backpropagation, it was introduced for this purpose by Rumelhart, Hinton, Williams[66] and some alterations were suggested by Zipser[84], and Werbos [80]. Backpropagation uses the chain rule to calculate the derivative of the loss function L with respect to each parameter(weights and biases) in the network. The weights are then adjusted by gradient descent algorithm (which we will go into detail at chapter 4). While it is not certain that backpropagation will reach a global minimum (unless the loss surface is convex 1 ) ,many researchers have worked on heuristic pre-training and optimization techniques that make them practically good enough for supervised learning tasks. To calculate the gradient in a feedforward neural network, backpropagation proceeds as follows. First,proceeds to the forward pass, an example is propagated forward through the network to produce a value αl j , at each node j at layer l and outputs αL at the output layer L . Then, a loss function value L( αL k , yk ) is computed at each output node k. Subsequently, for each output node j , we calculate the error where the first expression θL(αL j,yj) θαL j corresponds to the rate of change in respect to the output neuron j, and the second term measures how fast the activation function σis changing at zL j: δL j=θL(αL j,yj) θαL j σ0(zL j) (1.8) 1convex surface:when the local optima is equal to the global optima 5
CHAPTER 1. INTRODUCTION The equation above could be written in a more compact and matrix-based form, where ∇αL corresponds to the he rate of change of L with respect to the output activations, as: δL=∇αLσ0(zL) (1.9) Having computed the error of the output layer, we go to compute the error of the prior layer. The equation for computing the layer before is: δl= ((wl+1)Tδl+1)σ0(zl) (1.10) By combining the equations 1.9 and 1.10, we can compute the error at any layer. The backpropagation algorithm starts from the output layer L calculating the δL with equation 1.9 and moves to the previous layers with equation 1.10. The equation for the rate of change of the cost in respect to the bias of node j in layer lis: θL θbl j =δl j(1.11) A more clean and vectorized form of the equation above can be written as: θL θb =δ(1.12) The equation for the rate of change of the cost in respect to the weight that connects the node kand node jin layer lis: θL θwl jk =αl−1 kδl j(1.13) where α is the activation of the neuron input to the weight w and δ is the error of the neuron output from the weight w. θL θw =αIN δOUT (1.14) 6
Chapter 2 Word Embeddings Word embedding is a representation of a word in vector space where semantically similar words are mapped to nearby points. Word embeddings can be trained and used to derive similarities between words. They are an arrangement of numbers representing the semantic and syntactic information of words in a format that computers can understand. For many years, NLP systems and techniques would represent meaning of words using WordNet (George A. Miller, Princeton University, 1985) which is basically a very large graph that defines different relationships between words. In vector space terms, every word is a vector with one 1 and a lot of zeros (vocabulary size -1). This is a so called one-hot that describes words in the simplest way. However, this discrete representation had many issues, such as missing nuances, missing new words, the requirement of human labor to create and adapt, it was hard to compute accurate word similarity and most importantly when the vocabulary is large, the vector represantation is gigantic. The new approach of representing words was inspired by the quote "You shall know a word by the company it keeps"[27]. Instead of representing a word by its own index, represent a word by means of its words. This approach of representing words is by creating a dense embedding vector (word embedding). The word embeddings are derived by Vector Space Models (VSM) [67] which are divided in two categories which have been critically compared by Baron [2]. The first type of models is the count-based method (aka full document method) that compute the statistics of how often some words co-occur with its neighbor words in a large text corpus and then map those statistics to a low dimensional, dense vector. Some worth mentioning examples of this methodology are Hyperspace Analogue to Language [9], COALS method [21], Hellinger PCA [13]. The most popular model of the count-based method is the Latent Semantic Analysis [20] which we will cover at the section (2.1). The second 7
CHAPTER 2. WORD EMBEDDINGS type of VSM models are the predictive models which try to predict directly the word from its neighbors in terms of learned low dimensional, dense embedding vectors. Some models worth mentioning of this category are Semantic Role Labeling(SRL) [15], Mnih and Kavukcuoglu vLBL and ivLBL[55],[54],Levy [48] proposed explicit word embeddings based on a PPMI metric. At sections 2.2 and 2.3 we will cover the most popular models of the VSM predictive models , named Word2Vec and GloVe. The 2.1 and 2.2 are covered just to demonstrate way that GloVe 2.3 was conceived, therefore they are covered with not much details. The new approach of word representation tackles the problems of high dimensionality, the scalability of the vocabulary and the semantic relatedness of the words. 2.1 Latent Semantic Analysis Latent semantic analysis (LSA) is a methodology in natural language processing of analyzing relationships between a set of documents and the terms they contain by producing a set of concepts related to the documents and terms. LSA assumes that words that are close in meaning will occur in similar pieces of text. The term-document matrix that is created, is quite sparse. Therefore a mathematical technique called singular value decomposition (SVD) is used to reduce the number of rows while preserving the similarity structure among columns. Singular Value Decomposition [31] is a method for identifying and ordering the dimensions of the observation that exhibit the most variation. Once we have found where the most variation lies, we can find the best approximation of the original observation using fewer dimensions. Therefore, it can be used for dimensionality reduction tasks. Let X be a matrix with m terms and n documents where element (i,j) describes the occurrence of term i in document j co-occurrence matrix. According to SVD, there is a decomposition of X so that U and V are orthogonal matrices and Σ is a diagonal matrix.The values s1,...,sl are called the singular values, and u1,...,ul and v1 , ...,vl the left and right singular vectors. X x11 ··· x1n . . ..... . . xm1··· xmn = U u11 ··· u1r . . ..... . . um1··· umr Σ s11 ··· 0 . . ..... . . 0··· srr VT u11 ··· u1r . . ..... . . un1··· urn Moreover the The matrix product XXT gives us the the correlation between the terms over the set of documents and the XTX gives us the correlation between the documents over the set of terms. XXT= (UΣVT)(UΣVT)T= (UΣVT)(VTTΣTUT) = UΣVTVΣTUT=UΣΣTUT=UΣ2UT XTX= (UΣVT)T(UΣVT)=(VTTΣTUT)(UΣVT) = VΣTUTUΣVT=VΣTΣVT=VΣ2VT Since ΣΣT and ΣTΣ are diagonal we can safely conclude that U are the eigenvectors of XXT , V are the eigenvectors of XTX and both products have the same eigenvalues, 8
2.2. WORD2VEC given by the entries of ΣΣT or ΣTΣ . From Frobenius norm 1 [32] we can derive that by taking the k largest singular values (express the importance of every word), and their corresponding singular vectors, we get the rank k approximation to X with the lowest error. The word vectors of the corpus will be the k columns of the matrix . X x11 ··· x1n . . ..... . . xm1··· xmn ≈ ˆ U u11 ··· u1k . . ..... . . um1··· umk ˆ S s11 ··· 0 . . ..... . . 0··· skk ˆ VT u11 ··· u1k . . ..... . . un1··· xkn While this method solves the problem of dimensionality, it underlies some problems as well. First of all, the computational cost increases quadratically as the size of the matrix increases. Moreover when new words appear SVD has to be run again from scratch. Finally, it is able to find similarities between words, but it cannot represent relationships. 2.2 Word2Vec Word2Vec (Mikolov, 2013) is a predictive model that learns word embeddings on an online way. The main idea behind Word2Vec is to predict the surrounding words of every word in a window of length m, instead of capturing all the co-occurrence counts directly. It is simpler and faster than LSA and can easily add a new word to the vocabulary. The objective function of predictive VSMs (aka Neural probabilistic language models) aim to maximize the average log probability of any context word given the current center word where t is the number of tokens, m the co-occurrence window and θ all the variables we optimize using stochastic gradient descent. J(θ) = 1 T T X i=1 X −m≤j≤m,j,0 logp(wt+j|wt) (2.1) For p(wt+j|wt) : p(o|c) = exp(uT ovc) W P w=1 exp(uT wvc) (2.2) where o is the output word id, c is the center word id, u is the center word vector and v is the output vector. This objective function is not scalable and it takes much time to train when the vocabulary is large. Those two models are great at constructing word vectors, but when the vocabulary becomes too large the updates at each iteration take too much time. This problem is 1 Frobenius norm: is matrix norm of an m × n matrix A defined as the square root of the sum of the absolute squares of its elements 9
CHAPTER 3. FEEDBACK NEURAL NETWORKS 3.1.2.1 Architecture Long-Short Term Memory networks’ structure is like Simple RNN’s, with only difference on the hidden layer structure. While RNNs have a single layer, the LSTMs have four hidden layers. The LSTM is consisted of cells and gates, cells contain the information and gates regulate "how much"of information to let go, gates are composed of a sigmoid layer that outputs an interval from 0 to 1 where 0 stands for "pass no information"and 1 for "pass everything". In more detail, it is consisted of the forget gate ( ft ) which decides how much information (current and past) to pass to the network, the input gate ( it ) which decides what information to store at the cell, the cell state( Ct ) which is the updated state, and finally the output gate. Figure 3.2: Long-Short Term Memory Source : https://deeplearning4j.org/lstm.html 3.1.2.2 Forward Pass The first step is to decide what to input to the network, here is where forget gate comes in (3.7) where takes as input the previous state ( ht−1 ) and the current input ( xt ) and it outputs an interval between 0 to 1 to the candidate cell state( ˜ Ct )(3.8). Then we decide what values to update (3.9) at the input gate( it . After having computed candidate cell and the input gate we combine them with the previous cell state( Ct−1 ) to derive the current cell state ( Ct )(3.10). Finally we feed the cell state to the output gate in order to decide how much of the cell state to output(3.11) as well as to a tanh layer so to squash the values between -1 and 1(A.1). it=σ(W(i)xt+U(i)ht−1) (3.6) ft=σ(W(f)xt+U(f)ht−1) (3.7) ot=σ(W(o)xt+U(o)ht−1) (3.8) ˜ Ct= tanh(W(C)xt+U(C)ht−1) (3.9) Ct=ftCt−1+it˜ Ct(3.10) ht=ottanh(Ct) (3.11) 16
3.1. RECURRENT NEURAL NETWORKS 3.1.2.3 Backward Pass The original LSTM training algorithm [39] used an approximate error gradient calculated with a combination of Real Time Recurrent Learning [64] and Backpropagation Through Time (BPTT) [84].The BPTT part was truncated after one time-step, since memory blocks would deal with the longer dependencies.The truncating method has the benefit of making the algorithm online, meaning that weight updates can be made after every time-step.However in this report we will the extract the LSTM gradient with BPTT[Graves2005a], for further details look at appendix A. 3.1.3 Gated Recurrent Unit Gated recurrent unit (Figure 3.3) is another variant of recurrent units proposed by KyungHyun Cho[10]. It is closely related Long-Short Term Memory. The GRU also controls the flow of information like the LSTM, but without using a memory unit. It exposes the full hidden content without any control. 3.1.3.1 Architecture A GRU has two gates, a reset gate r , and an update gate z . The reset gate indicates how to combine the new input with the previous memory. The update gate defines how much of the previous state to keep.The basic idea of using a gating mechanism to learn long-term dependencies is the same as in a LSTM, but there are a few differences in terms of architecture. First of all, it doesn’t have an output gate so it has fewer parameters (two gates, instead of three). Secondly the input and forget gates are substituted by an update gate z and the reset gate r is applied directly to the previous hidden state. Thus, the responsibility of the reset gate in a LSTM is really split up into both r and z . Finally we don’t apply a second nonlinearity when we compute the output. Figure 3.3: Gated Recurrent Unit Source : https://deeplearning4j.org/lstm.html 3.1.3.2 Forward Pass The first step is to determine the input values, this is update gate’s task it will decide how much of the previous hidden state and how much of the candidate hidden state 17
CHAPTER 3. FEEDBACK NEURAL NETWORKS combines to get the new hidden state (3.12). After the update gate, the reset gate while it has the exact same functional form (3.13) as the update gate and all the weights are at the same size, what makes it different is its position at the model. The reset gate is multiplied by the previous hidden state it controls how much from the previous hidden state we will consider when we create the new candidate hidden state. In other words, it has the ability to reset the hidden state , if we set the reset gate to 0 from (3.14) we start over from a new sequence as if ht is the beginning of a new sequence. However this is not the full picture since ˜ ht is just a candidate for the hidden state, the actual hidden state will be a combination of previous hidden state ht−1 and the candidate hidden state ˜ htcontrolled by the update gate zt(3.15) . zt=σ(W(z)xt+U(z)ht−1) (3.12) rt=σ(W(r)xt+U(r)ht−1) (3.13) ˜ ht= tanh(W(h)xt+U(h)(ht−1r)) (3.14) ht= (1 −z)˜ ht+zht−1(3.15) 3.1.3.3 Backward Pass Gated Recurrent Units also use the BPTT algorithm in order to be trained. We will derive the gradients for E (error),W,U and by hand using the chain rule, for further details look at appendix B 3.2 Recursive Neural Networks Recursive Neural Networks (RNNs) [71], [61], [30], [16], [36] are perfect for settings that have nested hierarchy and an intrinsic recursive structure [73]. The syntactic rules of language are highly recursive, therefore we use that recursive structure with a model that complies with that property. It is important to notice that RNN don’t comprehend sentences as sequences but as hierarchies which makes them ideal for semantic representation tasks (paraphrase detection [71], relation classification, sentiment analysis, phrase similarity) but they can’t predict future items from a sequence(next word from a given sentence),something that Recurrent Neural Networks are very good at due to their linear structure.Recurrent Neural Networks represent sentences as parse trees(Figure 3.4). 18
3.2. RECURSIVE NEURAL NETWORKS What RNNs are very good at, is handling negation. Due to their hierarchical structure, when negation is spotted,the meaning is just being reversed. You have a label at every node of the tree, and the leaves of the tree represent words. Moreover another reason that RNN are so popular for natural language processing tasks, is that the input sequence length (sentence in our case) is not a restriction, it can take inputs of arbitrary lengths. The latter benefit is accomplished by making the input vector of sentence a predefined size no matter the length of the sentence. ([4],[35], [14]. Essentially what RNNs do is to merge the semantic understanding 1 of the words, then the grammatic understanding 2 of the phrase or sentence,which results to a parse tree representation of a phrase or a sentence. Having understood the words, and knowing the way words are put together we can retrieve the meaning of the sentence. Even though grammatical understanding is an assumption and it is not proven that it improves the accuracy, it is still under debate but we will assume that it helps the model. In short, it extracts from the sentence the syntactic structure, which indicates the relationship between phrases, and it identifies the meaningful phrases within the sentences and the relationship between them. In order to extract the vector representation of the sentence, the idea is to recursively merge pairs of representations of smaller segments to get representation that covers bigger senteces. The Recursive Neural Networks are trained with the Backpropagation Through Structure algorithm[30] which is very similar to the standard Backpropagation, we use the 1.10 and the 1.14, that was discussed at subsection 1.3.3 with three minor differences. Firstly we sum up the derivatives of W from all the nodes, secondly we split the derivatives at each node and finally we add different error messages from parent node and self node. Finally, it is assumed that the tree structured is given, which indicates that some preprocessing is required if it is not given. In our experiment we will use the Stanford Sentiment Treebank(SST) that was trained with the Stanford Parser[70],which is similar to max-margin parsing [78], to derive the tree structure is for every sentence. We will not go through the way that the sentence trees were constructed because we will add unnecessary complexity that is beyond the scope of this report, but at a high level explanation the parser that is used, have a loss term that penalizes the not plausible phrases. 3.2.1 Simple Recursive Neural Network This model (Figure 3.5) is the standard recursive neural network. The first step to take is to take a sentence parse tree and the sentence word vectors and begin from the bottom leaves to the top root of the tree. The mathematical formula to merge 1 semantic understanding: understanding of the meaning of a sentence, represent accurately the phrase as a vector in a structured semantic space 2grammatical understanding: it is identified the underlying grammatical structure of the sentence 19
CHAPTER 3. FEEDBACK NEURAL NETWORKS Figure 3.4: Recursive Neural Network Source : https://stats.stackexchange.com/questions/153599/recurrent-vs-recursive- neural-networks-which-is-better-for-nlp those two vectors (aka children) and create a new "word phrase"vector (parent) can be illustrated below (3.16). The h vector now represent the "this assignment"phrase. Having computed the vector representations of the sentences, we compute a s score 3.17 which represents the quality of the merge and decides which pair of representations to merge first. In oder to derive some meaning of the word vector, we feed it to a softmax layer (3.18)to compute the score over a set of sentiment classes, a discrete set of known classes that represent some meaning. This process happens till the model reach the root of the tree. Moreover it is important to note that the W parameters is the same for all the nodes of the trees. It is obvious that this is quite a naive approach and linguistic complexity is higher than that. It is too much to ask from a simple function like this to capture the language complexity. h1= tanh(W c1 c2 +b) (3.16) s1=Wscorep(3.17) ˆ y=sof tmax(W h1+b) (3.18) 3.2.2 Syntactically Untied SU-RNN One extension to the Simple RNN, the Syntactically Untied RNN model [73](Figure 3.6) was introduced to solve the problem mentioned at the previous subsection. What this model does, is to have unique weight matrices for every syntactic category. The syntactic categories are identified from the parser that determined the structure of the 20
3.2. RECURSIVE NEURAL NETWORKS Figure 3.5: Simple Recursive Neural Network Source: https://www.slideshare.net/jiessiecao/parsing-natural-scenes-and-natural- language-with-recursive-neural-networks tree. This has proven to increases the weight matrices to learn and outperforms the methods that were mentioned till that point,but the performance boost we gained is not significant. One impressive accomplishment of this model is that the trained weight matrices are capable of learning the semantics of the phrases. For example a determiner followed by a noun phrase (e.g. "an elephant") emphasizes more on the noun phrase than on the determiner. The architecture of the SU-RNN model compared to the Simple RNN is illustrated at Figure 3.6. Figure 3.6: Syntactically Untied Recursive Neural Network Source: https://wugh.github.io/posts/2016/05/cs224d-notes5-recusive-neural-networks/ 3.2.3 Matrix-Vector Recursive Neural Networks Another alteration of Recursive Neural networks is the Matrix-Vector Recursive Neural Networks [72] (Figure ?? )which improves the semantic representation of the sentences. The major difference is that not only we include a word vector (d-dimensional), but also a word matrix (dXd)(Figure 3.7). 21
CHAPTER 3. FEEDBACK NEURAL NETWORKS h1= tanh(W C2c1 C1c2 +b) (3.19) This approach not only represents the meaning of each word but also the effect that it has on the neighboring words. Suppose we feed two words to the model, a and b, the parent vector is the concatenation of the word vector of the former multiplied with the word matrix of the latter and the word vector of the later is multiplied by the word matrix of the former (Ab and Ba). In the figure’s example, the word matrix of "very"could also be the identity 3 multiplied by a scalar (above one) which indicates the impact it has to the word "bad". Figure 3.7: Matrix-Vector Recursive Neural Networks Source: https://wugh.github.io/posts/2016/05/cs224d-notes5-recusive-neural-networks/ Despite the fact that this is the most expressive model we have explored till now, it is still not good enough. It fails to capture the semantics of some relations. There have been observed three types of errors. [73] The first type (Figure 3.8)is the negated positives, this case occurs when something is classified as positive but one word turns it negative, the model can not capture the importance of that one word strong enough to flip the sentiment of the entire sentence. Figure 3.8: Negated positives Source: https://cs224d.stanford.edu/lecturenotes/LectureNotes5.pdf The second type (Figure 3.9) is the negated negative, where we say something is not 3identity matrix: square matrix with ones on the main diagonal and zeros elsewhere 22
3.2. RECURSIVE NEURAL NETWORKS bad. The MVRNN can not recognize that the word ”not” because it turns sentiment from negative to neutral. Figure 3.9: Negated Negative Source: https://cs224d.stanford.edu/lecturenotes/LectureNotes5.pdf The final type of errors (Figure 3.10) we observe is the ”X but Y conjunction”. In our example, X is negative but the Y is positive and the sentiment is positive. The MV-RNNs have some issues with such cases. Figure 3.10: X but Y conjunction Source: https://cs224d.stanford.edu/lecturenotes/LectureNotes5.pdf Thus, we must look for an even more expressive composition algorithm that will be able to fully capture these types of high level compositions. 3.2.4 Recursive Neural Tensor Network The third Recursive Neural Network variant that will be covered is the Recursive Neural Tensor Network(Figure 3.11). RNTN was conceived by Richard Socher [73] in order to solve the three types of errors we left of with at the subsection 3.2.3. Moreover it is famously quite sucessful for dealing with double negations. The Recursive Neural Tensor Network gets rid of the concept of a word matrix as well as the affine transformation 4 pretanh/σ concept that we saw before. To combine two word vectors or phrase vectors, we again concatenate them to form a vector ∈2d but instead of putting it through an affine function then a nonlinear, we put it through a quadratic first, then a nonlinear, such as: 4affine transformation: is a transformation composed of a linear function+ a constant 23
CHAPTER 3. FEEDBACK NEURAL NETWORKS h(1) =tanh(xTV x +W x) (3.20) Where V is a 3rd order tensor ∈2d×2d×d . The quadratic shows that we can indeed allow for the multiplicative type of interaction between the word vectors without needing to maintain and learn word matrices. Figure 3.11: One slice of a RNTN. Note there would be d of these slices. Figure 3.11: Recursive Neural Tensor Network Source: https://wugh.github.io/posts/2016/05/cs224d-notes5-recusive-neural-networks/ A major problem of the models we covered before is their inability to handle negation[69]. The table 3.1 below shows how the RNTN handles negations. Table 3.1: Negations Model Negated Positive Negated Negative RNN 33.3 45.5 MV-RNN 52.4 54.6 RNTN 71.4 81.8 3.2.5 Tree-Based Long-Short Term Memory Networks Tree-Based LSTM (Figure 3.12) was recently conceived by Kai Sheng Tai [77]. This is a hybrid model that combines LSTMs and Recursive neural network. It is important to notice that LSTMs were used for linear chained structured recursive neural networks (recurrent neural networks). The main difference that this model has with the standard LSTMs is that it is required the average of the child vectors and a special forget gate for each child. The idea behind this architecture is mostly to handle negation, by keeping in memory the semantically important words and forgetting the non significant. This process happens as the model goes through the tree structure. The Figure3.12 illustrates how the new memory cell c1 and hidden state h1 are composed with two children. 24
3.2. RECURSIVE NEURAL NETWORKS Figure 3.12: Tree-Based LSTM Memory Cell Composition Source: https://arxiv.org/pdf/1503.00075.pdf The Tree-LSTM behaves very similar to the standard LSTM, it takes as input vector xj with only difference that the input vector depends on the tree structure (1.3.2). If the tree is a constituency tree, the leaf nodes take the corresponding word vectors as input, if the tree is a dependency tree each node in the tree takes the vector corresponding to the head word as input. The two extensions that Tai(2015) proposed are the Child Tree-LSTM and N-ary Tree-LSTM. 3.2.5.1 Child-Sum Tree-LSTM Sum Tree-LSTM unit conditions its components on the sum of child hidden states hk , this model performs well with high branching factor tree structures or with structures that its children are not ordered. Dependency trees is a good choice of structure for that model since the number of dependents of a head can be quite variant. Let C ( j ) the set of children of node j and k∈C ( j ), the equations of the model are the following: ˜ hj=X k hk(3.21) ij=σ(Wixj+Ui˜ hj+bi) (3.22) fjk =σ(Wfxj+Ufhk+bf) (3.23) oj=σ(Woxj+Uo˜ hj+bo) (3.24) ˜ Cj= tanh(Wuxj+Uu˜ hj+bu) (3.25) 25
CHAPTER 4. NEURAL NETWORK TRAINING Figure 4.1: Vanilla vs Momentum Source : ’http://dsdeepdive.blogspot.com/2016/03/optimizations-of-gradient-descent.html’ a rough approximation of where the parameter will be, so now it can effectively look ahead by calculating the gradient with regards to the approximation of the future position and not the current one (4.6). According to Bengio[5] the estimated update prevents us from going too fast and results in increased responsiveness. vt=γvt−1+η∇θJ(θ−γvt−1) (4.6) θ=θ−vtSource :http ://dsdeepdive.blogspot.com/2016/03/optimizations −of −gradient −descent.html (4.7) The difference between the two approaches can be illustrated below at Figure 4.2. Figure 4.2: Momentum vs Nesterov Momentum Source: https://www.slideshare.net/cfregly/gradient-descent-back-propagation-and- auto-differentiation-advanced-spark-and-tensorflow-meetup-08042016 4.2.4 AdaGrad AdaGrad[23] adapts the learning rate for every feature which eliminates the need of manually tuning the learning rate. It adapts the learning rate to the parameters, performing larger updates for infrequent and smaller updates for frequent parameters. For this reason, it is well-suited for dealing with sparse data.[12] Moreover, Pennington [60] used Adagrad to train GloVe(section 2.3) word embeddings that we use at our 32
4.2. GRADIENT DESCENT EXTENSIONS experiment on the next chapter. The reason he used AdaGrad, is because infrequent words require much larger updates than frequent ones. Since AdaGrad uses different learning rate for every parameter θi at every time step t for the sake of convenience we assume gt,i (4.8) to be the gradient of the objective function of parameter i and gt (4.9) be the vector of all the parameters at time step t . Apart from the element-wise property of this approach, Duchi makes use of a diagonal matrix G∈Rdxd that is consisted of the sum of the squares of the gradients with respect to the parameter up to time step t, while it also has a smoothing term that prevents it from being divided with 0. It is adapting the learning rate by caching the sum of squared gradients with respect to each parameter at each time step. The reason that we use the squared sums is not specified, but it performs way better than taking the matrix without the square root operation. Finally the formula for computing the parameter can be seen below. gt,i =∇θJ(θi(4.8) θt+1 =θt−η √Gt +gt(4.9) Despite its high performance, Adagrad has a serious drawback which stems from the fact that the learning rate shrinks after some point due to its accumulation of the squared gradients in the denominator. This is the reason that it is notoriously aggressive at the machine learning community. 4.2.5 AdaDelta In order to tackle the learning rate shrinking problem Zeiler came up with a different way of adapting the learning rate. Adadelta [82] comes to rescue. Adadelta is an extension of Adagrad that alleviates its aggressively monotonically decreasing learning rate. It was suggested that instead of accumulating all the previous gradients it would be better to set a fixed window of size w and take the accumulated gradients of size w . Moreover, another alteration of Adagrad is the way it treats the past gradients. Instead of storing the past squared gradients, the sum of gradients is defined as a decaying average of all past squared gradients. The average of time step t depends only on the previous average and the current gradient. It is also used the momentum term ,that was covered at subsection 4.2.2, which determines how much offthe past average will affect the current average. E[g2]t=γE[g2]t−1+ (1 −γ)g2 t(4.10) The parameter update is defined similar to the AdaGrad but instead of the diagonal matrix Gtwe use the decaying average of the past squared gradients E[g2]t. 33
CHAPTER 4. NEURAL NETWORK TRAINING ∆θt=−η pE[g2]t+gt(4.11) Moreover the denominator of (4.11) is the root mean squared(RMS) error of criterion of the gradient, having noticed that Ziegel defined the decaying average of the squared parameter updates. However the RMS[∆θ]t is not known so it is approximated with the RMS of the parameter updates from the previous time step. Therefore the updates of the parameters can be computed as : ∆θt=RMS[∆θ]t−1 RMS[g]t gt(4.12) Something interesting about this approach is that the learning rate is irrelevant, as it is nowhere in the update rule. 4.2.6 RMSprop RMSprop is an unpublished adaptive learning method from Hinton at his coursera Machine Learning course that is commonly used from the deeop learning community (it is even a built-in function at tensorflow). RMSprop is very similar with AdaDelta, in fact is is just like the first part of AdaDelta but instead of γ there is a default value of 0.9 while its suggested initial learning rate is 0.001. Even though they were established the same period they were conceived independently. E[g2]t= 0.9E[g2]t−1+ 0.1g2 t(4.13) ∆θt=−η pE[g2]t+gt(4.14) 4.3 Hyperparameters 4.3.1 Learning Rate Learning rate can be thought as the rate that the parameter update based on its gradient. Choosing a proper learning rate can be difficult. A learning rate that is too small leads to slow convergence, while a learning rate that is too large can make the loss function fluctuate around the minimum or even diverge. 4.3.2 Regularization It is a method for preventing overfitting. It essentially works by setting a penalty a complexity penalty to the loss function. In practice, this means that it penalizes a 34
4.3. HYPERPARAMETERS function that is too non-linear and learns by heart the information that is contained in the training set and is not able to generalize well to new examples. In this paper we will mention the most popular regularizers that we will also use at the experiments. Let those be L2 regularizer and dropout regularizer. But why do we really need regularization? It doesn’t help the model perform well at the training set but perform well at the new examples(test set), which means that it minimizes the generalization error. The generalization error is the sum of the squared bias and variance of the trained model. The variance of the model indicates how much the model varies if we change the training set, the bias of the model is how close is the model to the true solution (the model that generated those instances). 4.3.2.1 L2 Regularization The L2 regularization method [40] adds a regularization term in order to prevent the coefficients to fit so perfectly to overfit. When it comes to neural networks it only regularizes the connection weights the hidden layers. In more detail, what we do is to penalize the square of the weight value for each hidden layer k and for each connection i,j . Notice that the sum of i,j from equation (4.15) corresponds to the Frobenius Norm therefore it can be written as (4.16) Ω(θ) = X k X i X j (W(k) i,j )2(4.15) Ω(θ) = X kkW(k)kF(4.16) The gradient to the regularizer with respect to the kth layer is two times the weight matrix : ∇w(k)Ω(θ)=2W(k)(4.17) It is important to notice that this is applied only at the weights, because we don’t expect to overfit the training set by changing the biases a lot but more by changing the weights that really determine how the function can become more or less non-linear. 4.3.2.2 Dropout Regularization In deep neural networks have been proposed two ways of dealing with over-fitting , the first one is the unsupervised pre-training [26](which we will not discuss because it will not be used in this experiment therefore it is beyond the scope of this paper), the second is dropout [37]. Dropout was proposed by Geoffrey Hinton as a technique for performing regularization. It works by randomly dropping nodes in a neural network and it emulates ensembles 1 of neural networks. The application can be seen 1train a group of prediction models, then average their prediction or take the majority vote 35
CHAPTER 4. NEURAL NETWORK TRAINING at figures 4.3,4.4 where Figure 4.3 illustrates a standard neural network while Figure 4.4 illustrates the very same neural network after having applied dropout. In practice, for each hidden unit once it have been computed we will independently set it to 0 (dropping out the value derived from the training) with a probability ,usually of 0.5. This process continues till we reach the output layer. Therefore as a result of the whole process the hidden units can’t collaborate with each other in order to generate complex patterns that might be useful to fit the training data so they are forced to extract a feature that is useful in general. Figure 4.3: Standard Feed-forward Neural Network Figure 4.4: After applying Dropout Source: http://cs231n.github.io/neural-networks-2/ The dropout regularization technique, it has an impact on both the forward and backward propagation algorithm for training a neural network. In more detail, regarding the forward propagation, we set a random binary mask m(k) with values 0 (dropout the weight of the unit) or 1(retains the value), when it comes to the backward propagation, when we backpropagate the gradient till the preactivation( z 1.3) we also need to multiply it by the mask vector, due to the chain rule. This practically means that many gradients will be set to zero so the backpropagation won’t flow through the hidden units that were dropped out. 36
Chapter 5 Experiments This chapter is dedicated to the practical comparison between the Constituent LSTM, with the Tree-Based GRU or Constituent GRU. It is important to notice that the experiments have been conducted 5 times and the results are the product of the averaged results of all the trials. We use the Stanford Sentiment Treebank(SST), and we use the standard train/dev/test splits of 6920/872/1821 for the binary classification subtask and 8544/1101/ 2210 for the fine-grained classification subtask (there are fewer examples for the binary subtask since the neutral instances have been excluded). The sentiment label at each node is predicted using the classifier covered at the next subsection 5.1.1. Moreover the SST have each sentence structured as constituent parse trees, therefore we will use the Constituent LSTM as a comparison to our model. Please find the code necessary for running those experiments to the next url: https://github.com/VasTsak/master_thesis. 5.1 Model comparison Before proceeding to the experiments we made the assumption that the Tree-based GRU will be faster to be trained because of its fewer parameters. The experiments proved us right. But training speed is just a factor (not even that critical) to select a model, what we really care about is its capability of being able to identify the underlying pattern just right, not learn the training set by heart (overfitting) nor ignoring some important features(underfitting). 5.1.1 Classification model The goal of the paper is to compare the performance of the Tree-GRU architecture against the Tree-LSTM architecture on sentiment classification tasks. In practice, the 37
CHAPTER 5. EXPERIMENTS model predicts a label ˆ y from a set of classes (2 for binary, 5 for fine grained) for some subset of nodes in a tree. The classifier and the objective function are exactly the same for both architectures. Let {x}j be the inputs observed at nodes in the subtree with root the node j. ˆ pθ(y|{x}j) = sof tmax(Wphj+bp),(5.1) ˆ yj= argmax y ˆ pθ(y|{x}j).(5.2) Let m be the number of labeled nodes in the training set and the superscript k be the kth labeled node, the cost function is: J(θ) = −1 m m X k=1 log ˆ pθ(y(k)|{x}(k)) + λ 2kθk2 2(5.3) 5.1.2 Binary Classification The binary classification is a problem that classifies whether the sentiment of the sentence is positive or negative. The process of the training can be seen at the Figures 5.1 ,5.2, and 5.3 where at Figure 5.1 it is plotted the average training time of each iteration and at Figures 5.2 are plotted the average loss of each iteration and at Figure 5.3 the training process1of Tree-GRU and Tree-LSTM. Figure 5.1: Binary Classification Average Training Time Figure 5.2: Binary Classification Average Training Loss All the plots have as their x-axis the number of epochs. The metrics that we plot are computed till the 12 th epoch and in cases of early stopping 2 we wouldn’t take into account the 0 or "Non Assigned Number"of the trial that its training stopped earlier but we would just skip it and calculate the results based on the rest trials that had a full training process. 1training process: the training and validation scores at each epoch. 2 early stopping: when the validation error increases for a specified number of iterations, the training process stops 38
5.1. MODEL COMPARISON Figure 5.3: Binary Classification Training Process 5.1.3 Fine-grained Classification The Fine-grained classification is a 5-class sentiment classification(1-Very Negative,2- Negative,3-Neutral,4-Positive,5-Very Positive). The experiment for the Fine-grained classification is under the same circumstances. The average time that each iteration lasted during the training process can be illustrated at Figure 5.4, the average loss that occured during the training process is illustrated at Figure 5.5 and the training process of the fine grained classification can be seen at Figure 5.6. Figure 5.4: Fine Grained ClassificationAverage Training Time Figure 5.5: Fine Grained Classification Average Loss 5.1.4 Hyperparameters and Training Details We have initialized the word representations using the pre-trained 300-dimensional GloVe vectors[60].The training of the model was done with AdaGrad[23] and a learning rate of 0.05 also we used the mini-batch gradient descent algorithm with batch size of 25. The model parameters were regularized with L2 regularization strength of 0.0001 and dropout rate of 0.5. For the training process we have applied the early stopping technique in order to avoid overfitting. The goal of this paper is not to achieve a state- of-art accuracy but to make a critical comparison between the two models therefore we 39
CHAPTER 5. EXPERIMENTS Figure 5.6: Fine Grained Classification Training Process won’t update the word representations during the training which boosts the accuracy approximately 0.05 (that is the accuracy boost gave to the Tree-LSTM). 5.2 Results The results of both the binary and fine grained classification can be seen in Table 5.1 we can see that Tree-based GRU have slightly better performance with the tree-based LSTM, but it is important to notice from Table 5.2 the standard deviation of the individual predictions that the prediction from Tree-GRU seem to be more fluctuate than the ones from Tree-LSTM therefore it is possible that this difference of performance can be random, because the standard deviation is quite high for the case of Tree-GRU. Something important to notice about the training process of fine grained classification is that, the Tree-based GRU would stop at the 8 th iteration while the LSTM would go all the way till the 12 th iteration. Moreover something else to notice is that the Tree-LSTM for fine-grained classification seems like it has some more training to do before it overfits, in contrast with the Tree-GRU which would overfit before having executed twelve iterations, which can be observed above (Figures 5.6). This may have to do with the hyperparameters that we have chosen. We have set the early stopping at 2 iterations(as the Tree-based LSTM paper had), if we would set it to 3 the Tree-GRU may keep on training till the 12th iteration. MoreoverTree-GRU’s training and validation scores seem to fluctuate more in the fine-grained classification 5.6 which may underlies unstable prediction and the need to train more. Table 5.1: Sentiment Classification Accuracy Model Binary Fine-grained Tree-LSTM 84.43 45.71 Tree-GRU 85.61 46.43 40
5.3. CONCLUSIONS AND FUTURE WORK Table 5.2: Sentiment Classification Standard Deviation Model Binary Fine-grained Tree-LSTM 0.35 0.55 Tree-GRU 0.93 0.98 5.3 Conclusions and Future Work We can conclude that there is a difference in terms of performance ,not that significant though, between the tree-based LSTM and tree-based GRU. Moreover, Tree-based GRUs are trained faster -computationally- and Tree-based GRUs seem to converge faster so, the training process can stop earlier.Therefore it is a good alternative,if not a substitute. The area of Natural Language Processing is very active area of research, tree-based architectures proved to be very powerful for Natural Language Processing tasks, mostly because of their capability of handling negations. Many potential projects can be developed around Tree-Based GRUs, namely a Child-Sum approach,or the of use unique reset and update gate for each child, or even try different GRU architectures [22]). For the end, one philosophical thought. Can you imagine an entire system of neural networks performing different tasks, so that the end result is something actionable. Like building a brain, the language processing system would be just a small part, but you may have a neural network to do part of speech tagging another neural network to do name entity recognition and another network to parse sentences into trees. Even a more challenging problem might be to figure out what is the general architecture we can use so that we don’t even have to tell the system to learn these things. In other words, a network of neural networks where each neural network can figure out what it should do on its own and be useful for the overall system in a gloal manner. 41
BIBLIOGRAPHY [52] W. S. Mcculloch and W. Pitts. “A logical calculus nervous activity.” In: Bulletin of Mathematical Biology 52.l (1990), pp. 99–115. issn: 00074985. doi: 10.1007/ BF02478259. [53] T. Mikolov, K. Chen, G. Corrado, and J. Dean. “Distributed Representations of Words and Phrases and their Compositionality.” In: Nips (2013), pp. 1–9. issn: 10495258. doi:10.1162/jmlr.2003.3.4-5.951. arXiv: 1310.4546. [54] T. Mikolov, K. Chen, G. Corrado, and J. Dean. “Efficient Estimation of Word Representations in Vector Space.” In: CoRR abs/1301.3781 (2013). url: http: //arxiv.org/abs/1301.3781. [55] A. Mnih. “Learning word embeddings efficiently with noise-contrastive estimation.” In: Nips (2013), pp. 1–9. issn: 10495258. doi: 10.3115/v1/P14-1023 . arXiv: arXiv:1011.1669v3. [56] Y. Nesterov. “A method of solving a convex programming problem with convergence rate O (1/k2).” In: Soviet Mathematics Doklady. Vol. 27. 2. 1983, pp. 372– 376. [57] A. Ng. “1. Supervised learning.” In: Machine Learning (2012), pp. 1–30. [58] C. Noam. “Syntactic Structures.” In: (1958). doi: 10.1515/9783110218329 . url:http://www.degruyter.com/view/product/41408. [59] B. Pang, L. Lee, and S. Vaithyanathan. “Thumbs up?: sentiment classification using machine learning techniques.” In: Proceedings of the Conference on Empirical Methods in Natural Language Processing (2002), pp. 79–86. issn: 1554- 0669. doi: 10 . 3115 / 1118693 . 1118704 . arXiv: 0205070 [cs] .url: http : //portal.acm.org/citation.cfm?id=1118693.1118704. [60] J. Pennington, R. Socher, and C. D. Manning. “GloVe : Global Vectors for Word Representation.” In: (2014), pp. 1532–1543. [61] J. B. Pollack. “Recursive Distributed Representations.” In: Artif. Intell. 46.1-2 (Nov. 1990), pp. 77–105. issn: 0004-3702. doi: 10. 1016/0004 - 3702(90) 90005-K.url:http://dx.doi.org/10.1016/0004-3702(90)90005-K. [62] N. Qian. “On the momentum term in gradient descent learning algorithms.” In: Neural Networks 12.1 (1999), pp. 145 –151. issn: 0893-6080. doi: http: / / dx . doi . org / 10 . 1016 / S0893 - 6080(98 ) 00116 - 6 .url: http : / / www . sciencedirect.com/science/article/pii/S0893608098001166. [63] H. Ritter and T. Kohonen. “Self-organizing semantic maps.” In: Biological Cybernetics 61.4 (1989), pp. 241–254. issn: 03401200. doi:10.1007/BF00203171. [64] F. Robinson A. J. Fallside. “The utility driven dynamic error propagation network.” In: (1987). 48
BIBLIOGRAPHY [65] F. Rosenblatt. “Principles of Neurodynamics. Perceptrons and the Theory of Brain Mechanisms.” In: Archives of General Psychiatry 7 (1962), pp. 218–219. issn: 0003-990X. doi:10.1001/archpsyc.1962.01720030064010. [66] D. E. Rumelhart, G. E. Hinton, and R. J. Williams. Learning representatons by backpropagating errors. 1986. doi:10.1038/323533a0. arXiv: arXiv:1011.1669v3. [67] G. Salton, A. Wong, and C. S. Yang. “A Vector Space Model for Automatic Indexing.” In: Commun. ACM 18.11 (Nov. 1975), pp. 613–620. issn: 0001-0782. doi: 10.1145/361219.361220 .url: http://doi.acm.org/10.1145/361219. 361220. [68] J. J. Schmidhuber. “Learning Complex, Extended Sequences Using the Principle of History Compression.” In: Neural Comput. 4.2 (1992), pp. 234–242. issn: 0899-7667. doi: 10 . 1162 / neco . 1992 . 4 . 2 . 234 . arXiv: 1103 . 0398 .url: http://dx.doi.org/10.1162/neco.1992.4.2.234. [69] R. Socher. “Recursive Deep Learning for Natural Language Processing and Computer Vision.” In: PhD thesis August (2014). [70] R. Socher, C. D. C. Manning, and A. Y. A. Ng. “Learning continuous phrase representations and syntactic parsing with recursive neural networks.” In: Proceedings of the NIPS-2010 Deep Learning and Unsupervised Feature Learning Workshop (2010), pp. 1–9. issn: 0302-9743. doi: 10.1007/978-3-540-87479-9 .url: http://wuawua.googlecode.com/files/LearningContinuousPhraseRepresentationsandSyntacticParsingwithRecursiveNeuralNetworks. pdf. [71] R. Socher, E. Huang, and J. Pennington. “Dynamic Pooling and Unfolding Recursive Autoencoders for Paraphrase Detection.” In: Advances in Neural Information Processing Systems (2011), pp. 801–809. issn: 9781618395993. url: http: //machinelearning.wustl.edu/mlpapers/paper{\_}files/NIPS2011{\_ }0538.pdf{\%}5Cnhttps://papers.nips.cc/paper/4204-dynamic-pooling- and - unfolding - recursive - autoencoders - for - paraphrase - detection . pdf. [72] R. Socher, B. Huval, C. D. Manning, and A. Y. Ng. “Semantic Compositionality through Recursive Matrix-Vector Spaces.” In: Proceedings of the 2012 Joint Conference on Empirical Methods in Natural Language Processing and Computational Natural Language Learning Mv (2012), pp. 1201–1211. issn: 9781937284435. doi:10.1162/153244303322533223. arXiv: arXiv:1301.3781v3. [73] R. Socher, A. Perelygin, and J. Wu. “Recursive deep models for semantic compositionality over a sentiment treebank.” In: Proceedings of the . .. (2013), pp. 1631– 1642. issn: 1932-6203. doi: 10.1371/journal.pone.0073791 . arXiv: 1512. 03385 .url: http://nlp.stanford.edu/{~}socherr/EMNLP2013{\_}RNTN. pdf{\%}5Cnhttp://www.aclweb.org/anthology/D13-1170{\%}5Cnhttp:// 49
BIBLIOGRAPHY aclweb.org/supplementals/D/D13/D13-1170.Attachment.pdf{\%}5Cnhttp: //oldsite.aclweb.org/anthology-new/D/D13/D13-1170.pdf. [74] I. Sutskever. “Training Recurrent neural Networks.” In: PhD thesis (2013), p. 101. arXiv: 1456339 [arXiv:submit]. [75] I. Sutskever, O. Vinyals, and Q. V. Le. “Sequence to Sequence Learning with Neural Networks.” In: CoRR abs/1409.3215 (2014). url: http://arxiv.org/ abs/1409.3215. [76] R. S. Sutton. “Learning to Predict by the Method of Temporal Differences.” In: Machine Learning 3.1 (1988), pp. 9–44. issn: 08856125. doi: 10.1023/A: 1018056104778.url:citeseer.ist.psu.edu/sutton88learning.html. [77] K. S. Tai, R. Socher, and C. D. Manning. “Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks.” In: Acl (1) (2015), pp. 1556–1566. issn: 9781941643723. doi: 10 . 1515 / popets - 2015 - 0023 . arXiv: 1503.0075.url:http://aclweb.org/anthology/P/P15/. [78] B. Taskar, D. Klein, M. Collins, D. Koller, and C. Manning. “Max-Margin Parsing.” In: Proc. EMNLP (2004), pp. 1–8. [79] O. Vinyals, A. Toshev, S. Bengio, and D. Erhan. “Show and Tell: A Neural Image Caption Generator.” In: CoRR abs/1411.4555 (2014). url: http://arxiv.org/ abs/1411.4555. [80] P. J. Werbos. “Backwards Differentiation in AD and Neural Nets: Past Links and New Opportunities.” In: Lecture Notes in Computational Science and Engineering 50 (2006), pp. 15–34. issn: 14397358. doi:10.1007/3-540-28438-9_2. [81] W. Zaremba and I. Sutskever. “Learning to Execute.” In: CoRR abs/1410.4615 (2014). url:http://arxiv.org/abs/1410.4615. [82] M. D. Zeiler. “ADADELTA: An Adaptive Learning Rate Method.” In: CoRR abs/1212.5701 (2012). url:http://arxiv.org/abs/1212.5701. [83] M. Zhu, Y. Zhang, W. Chen, M. Zhang, and J. Zhu. “Fast and Accurate Shift- Reduce Constituent Parsing.” In: Proceedings of the 51st Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) (2013), pp. 434– 443. url: http://www.aclweb.org/anthology/P/P13/P13- 1043.pdf{\% }5Cnhttp://www.aclweb.org/anthology/P13-1043. [84] D. Zipser and R. J. Williams. “Gradient-Based Learning Algorithms for Recurrent Networks and Thei r Computational Complexity.” In: Back-propagation: Theory, Architectures and Applications (1995), pp. 433–486. 50
Appendix A Appendix 1 Let E is the error ,δht=θE θht , we seek to find δot,δCt,δit,δ˜ Ct,δft, , δCt−1. δot=θE θot =θE θht θht θot =δhttanh(Ct) (A.1) δCt=θE θCt =θE θht θht θCt =δhtot(1 −tanh2(Ct)) (A.2) δit=θE θit =θE θCt θCt θit =δCt˜ Ct(A.3) δ˜ Ct=θE θ˜ Ct =θE θCt θCt θ˜ Ct =δCtit(A.4) δft=θE θft =θE θCt θCt θft =δCtCt−1(A.5) δCt−1=θE θCt−1 =θE θCt θCt θCt−1 =δCtft(A.6) 51
Appendix B Appendix 2 Given δht=θE θht we seek to find δ˜ htht,δrtand δzt δ˜ ht=θE θ˜ ht =θE θht θht θ˜ ht =δht(1 −z) (B.1) δrt=θE θrt =θE θ˜ ht θ˜ ht θrt =δ˜ htht−1Uh(1 −˜ h2 t) (B.2) δzt=θE θzt =θE θht θht θzt =δht(ht−1−˜ ht) (B.3) 53