Dynamic Cell Structure via Recursive-Recurrent Neural Networks
Xin Qian, Matthew Kennedy, and Diego Klabjan

TL;DR
This paper introduces a dynamic neural architecture search method that constructs customized cell structures for each data sample and time step, improving efficiency and accuracy in recurrent neural networks.
Contribution
It presents a novel recursive-recurrent neural network algorithm that dynamically searches for optimal cell structures tailored to individual data samples.
Findings
Achieves higher prediction accuracy than GRU in language modeling.
Discovers high-performance cell architectures through experiments.
Demonstrates efficiency in architecture search for recurrent models.
Abstract
In a recurrent setting, conventional approaches to neural architecture search find and fix a general model for all data samples and time steps. We propose a novel algorithm that can dynamically search for the structure of cells in a recurrent neural network model. Based on a combination of recurrent and recursive neural networks, our algorithm is able to construct customized cell structures for each data sample and time step, allowing for a more efficient architecture search than existing models. Experiments on three common datasets show that the algorithm discovers high-performance cell architectures and achieves better prediction accuracy compared to the GRU structure for language modelling and sentiment analysis.
| Wiki-5k (BPC) | Wiki-10k (BPC) | |||
| Val | Test | Val | Test | |
| RRNN | 2.58 (-5.5%) | 2.63 (-1.9%) | – | – |
| RRNN-GRU | – | – | 2.43 (-5.8%) | 2.42 (-5.8%) |
| GRU | 2.73 | 2.68 | 2.58 | 2.57 |
| SST (Accuracy) | PTB (Perplexity) | |||
| Val | Test | Val | Test | |
| RRNN-GRU | 65.1% (-0.8%) | 68.7% (-5.2%) | 281 | 239 |
| GRU | 64.6% | 65.3 % | 247 (-12.1%) | 239 |
| Wiki-10k | SST | PTB | |
|---|---|---|---|
| Batch size | |||
| Learning rate | |||
| Scoring margin | |||
| Gradient clipping threshold | |||
| Alternate frequency |
| Wiki-5k/Wiki-10k | SST | PTB | |
|---|---|---|---|
| Batch size | |||
| Learning rate | |||
| weight decay coefficient |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsNeural Networks and Applications · Model Reduction and Neural Networks · Neural Networks and Reservoir Computing
MethodsSigmoid Activation · Tanh Activation · Softmax · Long Short-Term Memory · Gated Recurrent Unit
Dynamic Cell Structure via Recursive-Recurrent Neural Networks
Xin Qian
Matthew Kennedy
Weinberg College of Arts and Sciences, Northwestern University
Diego Klabjan
Abstract
In a recurrent setting, conventional approaches to neural architecture search find and fix a general model for all data samples and time steps. We propose a novel algorithm that can dynamically search for the structure of cells in a recurrent neural network model. Based on a combination of recurrent and recursive neural networks, our algorithm is able to construct customized cell structures for each data sample and time step, allowing for a more efficient architecture search than existing models. Experiments on three common datasets show that the algorithm discovers high-performance cell architectures and achieves better prediction accuracy compared to the GRU structure for language modelling and sentiment analysis.
1 Introduction
First proposed by Hopfield [12], recurrent Neural Network (RNN) models excel at machine learning tasks that involve sequential data such as natural language processing. Researchers soon noted that a major obstacle of RNN models is in backpropagation when computing gradients. Since RNNs are trained by backpropagation through time, when the recurrent structure is unfolded into a huge feed-forward network with many layers, gradients tend to grow or vanish exponentially in the same way as in very deep feed-forward neural networks [20]. Many extensions of RNN models, such as Long Short-Term Memory (LSTM) [11] and Gated Recurrent Units (GRU) [5], are proposed to address this problem. These models achieve state-of-the-art results in many machine learning tasks like language modeling [6] and speech recognition [15, 22].
However, the cell structure of these hand-crafted RNN models, like LSTM and GRU, is fixed across all time steps and data samples. It is also a time-consuming and tedious effort to find a suitable cell structure through trial and error [19]. Lastly, there is no universal answer to which cell structure to use when facing different types of data and a different problem at hand. Therefore, a more flexible model that can automatically determine the cell structures based on a finite set of trainable parameters is needed to deal with more and more complicated and diversified data sources and problems.
There is another line of research about Recursive Neural Network (RecNN) models [24]. A RecNN model is defined over recursive tree structures – each node of the tree corresponds to a vector computed from its child nodes, and the information passes from the leaf nodes and internal nodes to the root node in a bottom-up manner. The model produces a structured prediction such as a tree by applying the same set of trainable parameters recursively. Derivatives of errors are computed with back-propagation over the tree structures [8]. RecNN has shown great success in learning tree structures of certain natural language processing tasks [25] because the structures it dynamically produces are customized for each data sample.
We consider how to replace the cell structure in RNN models to be time-variant and sample-dependent. We note that the equations governing a cell can be represented as a computational tree where each non-leaf node corresponds to a vector that is computed from the vectors on its two child nodes. The initial multiset of vectors is composed of the current feature vector at time and all vectors produced by the previous cell (hidden state representation). If we augment this multiset with constant vectors, such as the zero vector, we can then express mathematical equations behind a cell as a tree on this multiset. RecNN is an appropriate model to capture such a tree by means of a finite set of trainable parameters. In summary, our proposed model is using RecNN in each time step as a replacement for a fixed set of equations. In this way we obtain an architecture with cells depending on time and on each individual sample. In addition to this flexibility, the approach does not require hand-crafting of cells.
Our model shows great results on a series of language modeling and sentiment prediction tasks. In the experiments we show that RRNN is able to design sample-dependent tree structures on the Wikipedia dataset and achieves 5.5% improvement in Bits per Character (BPC) compared to GRU. The performance on the datasets also show the advantage of dynamically designing cell structures for each sample.
The major contribution of this paper is a novel architecture that dynamically searches for the structure of cells in an RNN. Our model, called a Recursive-Recurrent Neural Network (RRNN), recursively designs the cell structure with the help of a scoring function and allows us to build different cell structures under a fixed set of parameters. The proposed model can generate the cell structure of some traditional RNN models, like GRU and LSTM which we establish theoretically. Most importantly, the output tree structure of hidden cells in RRNN are customized based on each data sample, and therefore they are time-variant and data-dependent. Besides, we define a new tree distance metric that can measure the difference between the tree with vectors on each of its nodes. We also exhibit and prove the sufficient and necessary conditions for avoiding the gradient exploding and vanishing problem that usually appears in recurrent neural network models. While such results are known for RNNs, they have not yet been established for RecNNs. Furthermore, our result applies to RRNNs which are a combination of RNN and RecNN.
The rest of the manuscript is structured as follows. In Section 2 we review the literature while in Section 3 we present the RRNN model, including an algorithm to construct trees, the design of the loss function, and other extensions. Section 4 presents some properties of the RRNN model. In Section 5 we introduce the data sets and discuss all experimental results. We defer the proofs of the theorems and other technical details to Appendix.
2 Literature Review
A recurrently connected structure in RNN can improve the performance of a model by its ability to infer sequential dependencies [16]. Despite their success, vanilla RNN models are still limited by the algorithms employed due to the problems of exploding or vanishing gradients that may appear in the training phase [2]. LSTM [11] is one of the most popular ways to address this problem. Many variants are then proposed to improve the performance of LSTM [10, 14]. RNN models often work well if a hand-crafted cell structure is well-designed, which requires time and expertise, and it leads to a fragile setting that works only on a particular problem or, worse, on a single dataset. This is clearly less general and less flexible than the method proposed in this paper where the cells are algorithmically designed.
Recursion is the division of a problem into subproblems of the same type and the application of an algorithm to each subproblem. It can help with augmenting neural architectures and improving the generalization ability of a model [3]. RecNN greedily searches hierarchical tree structures and achieves state-of-the-art performances on tasks like semantic analysis in natural language processing and image segmentation [24, 25].
To provide better flexibility and robustness, automatically searching a neural network architecture is thus a logical next step. Neural Architecture Search (NAS), a subfield of AutoML, is a method which algorithmically finds an architecture; it has significant overlap with hyper-parameter optimization and meta-learning [7]. A simple approach to NAS is to build a layer-chained neural network where layers are differentiated by their choices of operations (pooling, convolution, etc.), activation functions (ReLU, Sigmoid, etc.), width, etc. [4, 26, 1]. Despite its impressive empirical performance, NAS is computationally expensive and time consuming [29].
Various methods of producing novel cell structures for RNNs have been recently proposed. [28] introduce a reinforcement learning approach that utilizes policy gradient to search for convolutional and recurrent neural architectures. However, the reinforcement learning approach is computationally expensive in the sense that obtaining an architecture with state-of-the-art performance on CIFAR-10 and ImageNet requires 1,800 GPU days [29]. [21] accelerate the search process by sharing parameters among potential architectures. [23] introduce a more flexible algorithm that searches for novel RNNs of arbitrary depth and width. [17] relax the discrete architecture space by continuous probability vectors and utilize a gradient based optimization method to derive an optimal architecture. All these methods are extremely computationally demanding and they yield a fixed network architecture for all times and samples. Some exceptions are in [9] and [27] where the proposed models automatically adjust the number of layers of the LSTM model based on time and sample but the cell structures are static. Our RRNN model further extends this property such that the predicted cell structures are time-variant and sample-dependent.
3 Recursive-Recurrent Neural Network Model
Generally, RNNs consist of two parts which are a hidden cell (recurrent cell) and an output layer. A single sample input of an RNN is a sequence of vectors , labeled by time step . Given a hidden state , the -th recurrent cell defines the next hidden state by . The output layer is usually a simple network that takes and as input and returns as output. These two equations are applied for .
Function defined above is time-invariant and thus remains the same in all time steps and for all samples. To address this shortcoming, we propose a new model that can dynamically design the recurrent cell structure (i.e. generate different functions ) with respect to the argument vectors. This is inspired by the idea of RecNNs, thus we call it the Recursive-Recurrent Neural Network model. A dynamic architecture has two advantages: (1) no need to hand-craft a cell, and (2) it automatically adjusts based on timestep and sample.
A simple RecNN model starts with a set of input nodes with corresponding embedding vectors . Two nodes are merged into a parent node using a pair of weight matrices and , a bias vector , and an activation function that provides non-linearity. For two nodes and , their parent, denoted by , is also a node with the embedding vector calculated by . In each iteration, we compute the scores for all pairs of nodes and select the pair of nodes with the highest score. We next merge nodes and into the parent node and remove the two child nodes and from further consideration. This procedure repeats until all nodes are merged and only one parent node remains. The set of parameters and activation function are shared across the whole network. The RecNN model returns and the binary tree rooted at as the model output.
The RRNN model replaces the fixed hidden cell of RNN by a recursive tree, dynamically determined by an algorithm similar to RecNN. Note that, even with the fixed set of parameters and activation function , the RecNN model can dynamically produce different tree structures based on input nodes (vectors). Therefore, in RRNN, the recurrent cell is different across all time steps and data points. We further discuss the RRNN model in the following sections.
3.1 Recursive-Recurrent Neural Network Model Framework
We start with an example of how to represent the hidden cell structure of GRU to be a binary tree with computational information on it. In the following we assume is a given sample, where is a sequence of input vectors. Recall that the GRU equations are:
[TABLE]
where and are parameter matrices and bias vectors of GRU, respectively. Equations (1) – (4) jointly define the function of the -th hidden cell of GRU. As shown in Figure 1, the above equations can also be regarded as a binary tree where each node of the tree corresponds to a 3-tuple (binary operator, activation function, bias vector), and each edge is associated with a trainable matrix or identity matrix.
The tree structure can be achieved in the scheme of RecNN by giving a multiset of initial nodes . Assuming an appropriate scoring function, in the first iteration, we can find that the parent node that combines and with parameters and operations has the highest score, thus we merge two nodes and together to achieve node . In the second iteration, we find that the parent node has the highest score among all potential parent nodes, thus we again take two nodes and from the node set and merge them to be . After iterations, we end up with one node and this is exactly the output of the -th hidden cell of GRU. We can prove that, with an appropriate choice of the scoring function, a RecNN can find the tree in Figure 1 and thus it can produce GRU. The statement is given in Section 4.1 and the proof is in the Appendix.
Next, we present the RRNN model. The RRNN model has the same recurrent structure as RNN and an algorithm for building the hidden cell. We start with the case where only one hidden state needs to be transferred between two consecutive hidden cells (GRU falls in this case, but in LSTM we have two states, i.e. the hidden state and the memory state). We extend the model to be compatible with multiple hidden states in Appendix B.
For each hidden cell of RRNN, we build up a binary tree from a multiset of initial nodes with corresponding vectors on each node. A set of trainable parameter matrices and bias vectors, activation functions, binary operations, and a scoring function is given prior to the construction of the tree. We denote and with as the set of trainable weight matrices, with as the set of trainable bias vectors, and as the set of available activation (unary) functions and binary operations, respectively. Besides, a scoring function , depending on a set of trainable parameters , is given. A multiset of initial nodes with is also given as input of the hidden cell. We do not distinguish between a node and its corresponding vector in the following discussion, however we note that nodes in the tree are unique while the corresponding vectors form a multiset. The tree shown in Figure 1 is the equivalent RRNN representation for the GRU cell.
Formally, the RRNN hidden cell can be understood as a function , where is the set of all possible (binary) computational trees such that each node of the tree corresponds to a vector and a 3-tuple , and each directed edge from each one of the two child nodes to its parent node is associated with a weight matrix.
Function can be recursively defined as
[TABLE]
where and . For , function maps multiset to multiset by the following three steps: (i) , (ii) , (iii) , where are the two child nodes combined to get .
Note that contains only one node, i.e. . Function then takes and returns the tree rooted at (we can discover it by unfolding the collapsing decisions and tracing each parent node down to its child nodes until all initial nodes appear) and the corresponding vector as the output. We point out that by definition the produced binary tree is full, i.e. each node has exactly 2 or 0 child nodes.
We next specify the recursive relationship of our cells. To this end, let multiset consist of several copies of , several copies of and other constant vectors such as the vector of all zeros or all ones or unit vectors. The numbers of each of them can vary by . The transition equations and cell output are as follows:
[TABLE]
It remains to specify the loss function. The generic function is as follows with further details provided in Section 3.3. We assume that a sample consists of where is a sequence of ground truth labels. We also assume that we are given a ground truth binary tree which is specified as in Figure 1 but without the trainable matrices and bias vectors. The target tree usually does not depend on . Ideally this target tree should not be specified but we leave this as future research work.
One further complication is the fact that the ground truth tree does not have a unique representation. Indeed, since the leaf nodes corresponding to are unordered, there are several isomorphisms of a given tree that yield the same underlying ground truth transition function, i.e. mathematically equivalent expressions. To this end, let be the set of all isomorphic trees to . Note that we do not need to consider the isomorphisms when leaf nodes are ordered, as is the case in [24].
The set of all trainable parameters in RRNN is denoted by . The loss function is specified by
[TABLE]
where function is the standard loss function, measures the difference of two trees, and is the margin function. These two are described in detail in Section 3.3. The minimum operation over isomorphic target trees can also be replaced by expectation.
3.2 Cell Tree Construction
Several changes of constructing the cell tree are made for practical concerns. Functions can be regarded as iterations of merging two nodes (vectors). Multisets can have multiple copies but in practice we keep a single copy that is reused. The new set consists of three fixed sets of vectors, namely as the set of vectors from the data samples, as the set of vectors from the previous hidden cell, and as the set of auxiliary vectors such as the zero vector, etc., together with the set as the set of generated parent nodes. The model takes the new set as the set of all potential choices of child nodes to build the -th parent node . Then we set and step to the -th iteration. We further need a hyper-parameter corresponding to the number of iterations of the tree construction steps. The practical algorithm for constructing the computational tree for the -th hidden cell of RRNN is exhibited in Algorithm 1. It is worth mentioning that the number of iterations in Algorithm 1 might be different from the number of nodes in the predicted tree. A vector might be chosen several times to serve as a child node in Algorithm 1. In this case, the number of nodes in the predicted tree is larger than the number of iterations .
3.3 Loss Function
We discuss the definition of the tree distance (TD) and the scoring margin in this section.
Score Margin
To give scoring more partitioning power, we incentivize it to leave a significant margin between the score of the highest-scoring vector and the second-highest vector for each node. Recall the definition of and from Section 3.1. We further define to be the vector with the second highest score among the vectors in . In Algorithm 1 the analogous to is . The scoring margin function is thereby defined as where is a hyper-parameter. Intuitively, the margin function incentivizes scoring to increase the gap between the scores of the highest and second-highest vectors to at least . We divide by so that the overall scale of this loss term is not affected by the choice of .
Tree Distance
For convenience, in the discussion of this part, we use and to denote the predicted tree and the target (ground truth) tree, respectively. For any binary tree , we use to denote all internal (non-leaf) nodes of . We use to denote the labeling of such that the root node of has index 1, and if a node has index , then its left and right child nodes have index and , respectively. For a node , we use to denote the subtree of rooted at node . In addition, we use and to denote the node and the corresponding vector with index in tree , respectively.
Given two binary trees and , we define
[TABLE]
to be the vector differences (VD) of these two trees. The tree distance between and is the sum over all minimum VD values between a sub-tree of and all sub-trees of :
[TABLE]
This expression matches each subtree in with the closet subtree in with respect to VD, and therefore the TD measures the difference of vectors on all of the nodes of the two trees.
4 Properties of RRNN and Gradient Control
In this section, we state some properties of the RRNN model and show how to avoid gradient exploding and vanishing during training of RRNN. We give theorems in this section and defer the proofs to the appendix.
4.1 Expressibility of RRNN
We argue that if we carefully choose sets , the quantity , and the scoring function , then Algorithm 1 can replicate the GRU and LSTM equations. We give the formal statements in this section and defer the choice of the sets and the proof to Appendix C.
Theorem 1**.**
There exists a scoring function such that Algorithm 1 generates GRU equations (1) – (4) with an appropriate choice of , and .
Theorem 2**.**
There exists a scoring function such that Algorithm 1 (applied twice) generates the LSTM equations with an appropriate choice of , and .
4.2 Controlling Gradient
As introduced in [2], the exploding gradient problem refers to the large increase in the norm of the gradient during training. This is due to the fact that the gradient of long-term dependencies grows exponentially quicker than for short-term dependencies. The vanishing gradient problem, on the other hand, refers to the behavior that the gradients of long-term dependencies go to zero exponentially. [20] introduce a sufficient condition of vanishing gradient and a necessary condition of exploding gradient for a simple RNN. In this section, we extend their results to a more general case – we provide these two conditions for our RRNN model. We note that our result as a special case applies to RecNN where such conditions have not yet been established.
We consider the case where only one hidden state is returned by the -th hidden cell of the RRNN model. The loss function (6) can be written as where each is a function of all parameters in . For , the gradient of with respect to comes from cells, namely , where refers to the direct gradient of with respect to directly appearing within the -th hidden cell. If is a matrix, then we mean , where is an appropriate matrix vectorization. The exploding (vanishing) gradient problem is defined by going to ([math]) exponentially fast as goes to and is fixed as a constant. For simplicity, we consider the case where and .
We state a simplified version of the theorems here and defer the full version to Appendix D. We argue that most of the time these conditions are met in practice and we elaborate them one by one in Appendix D.2.
Theorem 3** (Sufficient condition of gradient vanishing).**
Under certain conditions given in Theorem 7, we have as , i.e., the vanishing gradient problem occurs.
Theorem 4** (Necessary condition of gradient exploding).**
If we observe the vanishing gradient problem, then at least one of the conditions listed in Theorem 8 holds.
5 Experimental Results
In this section, we present numerical results by comparing our algorithm with a GRU baseline model. The experiments are conducted on three datasets, and the source code is available at http://after_accepted.
We test two versions of the RRNN algorithm. The first one is the full algorithm we presented in Algorithm 1. The second one, which we call it RRNN-GRU, is a simplified version of the RRNN model where we limit the tree structure to be exactly the same as GRU. This model has a limited tree search space and the only dynamic component is the choice of the tuple to use on each pair of parent-child nodes, so the positioning of weights in the cell is flexible. Therefore, RRNN-GRU is still time-variant and data-dependent. In addition, we alternate between training the parameters and training the scoring neural network consisting of a 2-layer fully connected neural network, while continuously training the output layer. The frequency (in epochs) that we switch training phases is set as a hyperparameter of the RRNN-GRU model. Due to the model architecture, training can sometimes be unstable with exploding gradients which we clip. The baseline model is the single layer GRU which has 100-dimensional hidden states.
For both 100-dimensonal character and word embeddings, we used the pre-trained embedding vectors from GloVe111https://nlp.stanford.edu/projects/glove/. The Adam optimizer is used for all experiments and random initial weights are selected. A random search on hyperparameters is used for all RRNN-GRU models and GRU models. We train the model parameters on the training set and select the optimal parameters and hyperparameters based on the performance measure on the validation set. Then we use this set of hyperparameters and the optimized model parameters to predict on the test set. We test the RRNN model only on the Wikipedia dataset. We report the performance on both validation and test sets for all datasets in Table 1 and list the optimal hyperparamers in Appendix E.2. Further details about the implementations are given in Appendix E.1.
5.1 Datasets and Settings
The Wikipedia task is to predict the next character on text drawn from the Hutter prize Wikipedia dataset222https://cs.fit.edu/~mmahoney/compression/textdata.html [13]. We remove all numbers, punctuation, XML tags, and markup characters so that 26 English characters and space are left in the raw text. Performance is measured using BPC (the smaller the better). For RRNN-GRU, we randomly select 10,000 20-character sequences for the training set, along with 1,000 sequences for validation and 2,000 for testing, such that no sequences overlap. For RRNN, the training set has 5,000 sequences while the validation and test sets remain of the same size.
The Stanford Sentiment Treebank (SST) dataset333https://nlp.stanford.edu/sentiment/treebank.html [25] is a sentiment analysis task involving classifying one-sentence movie reviews as positive, negative, or neutral. We obtain the dataset from the torchtext package and use the full 8,544-sample training set, along with a randomly-chosen 1,000 samples for validation and 2,000 for testing. Since the training data has variable length, we prepend each sample with zeros to make each sample be the same length. The performance is measured in the accuracy of correctly predicting sentiments (the higher the better).
We also perform word-level language modeling using the Penn Treebank (PTB) dataset444https://catalog.ldc.upenn.edu/LDC99T42 [18], a corpus containing articles from the Wall Street Journal. We obtain this dataset from the torchtext package and randomly select a 10,000 sample subset of 20 words each, along with 1,000 samples for validation and 2,000 for testing. We predict over all 10,001 unique words in our subset without eliminating uncommon words. The performance is measured in perplexity (the smaller the better).
5.2 Discussion
From Table 1 it is clear that RRNN-GRU outperforms GRU by 5.8% on the Wikipedia dataset while RRNN improves the results of GRU by 5.5% on validation set and 1.9% on test set with a simple set of hyperparameters. On SST, RRNN-GRU also beats GRU by 0.8% and 5.2% on validation and test sets, respectively. These experiments show that the data-dependent structures do help improve the prediction power of the model and achieve better performance. Meanwhile, RRNN-GRU matches the performance of GRU on PTB. Its performance on the test set of PTB can be improved by a more dedicated hyperparameter search.
One interesting observation of the full RRNN model is the evolution of the predicted tree structures. Figure 3 of Appendix A shows the common tree structures we find at the beginning epochs while Figure 4 of Appendix A shows the common tree structures at later epochs (near the point where optimal performance is achieved on the validation set). The tree structures tend to be balanced in the beginning epochs since the structure of the ground-truth tree plays a significant role. In later epochs, the output layer dominates the predicting ability and therefore the model tends to feed simple to the output layer.
Another interesting observation lies in the dynamics of the RRNN-GRU model. Let us denote to be the index of parameter tuple that the -th internal node of -th sample on the -th time step in -th epoch, and we further set to measure the number of changes in the choice of parameter tuples between -th epoch and -th epoch. Then we should expect the quantity to be decreasing as increases since the model is expected to become more stable as the training goes on and the choice of indices of parameter tuples should also become more stable. Figure 2 in Appendix A shows the plot of vs epochs which supports our hypothesis.
Acknowledgments
The authors would like to acknowledge and thank Intel for providing access to Intel’s Computing environment.
Appendix A Figures
Appendix B Extensions of RRNN model
The exposition so far handles the case where only one state vector transfers between hidden cells of the RRNN model, and it can capture the structure of GRU. However, LSTM, for example, has two state vectors and to transfer between cells. In this section we extend the RRNN model to be compatible with transferring multiple state vectors. Suppose that a total of vectors, , are the output of the -th hidden cell. The transition equations and cell output are thereby
[TABLE]
where each has the same definition as the function defined in (5), and is the multiset consisting of multiple copies of , , , and possible other constant vectors. In practice, we use Algorithm 1 times to build functions .
The loss function is redefined as
[TABLE]
where , and is the ground truth binary tree.
As an example, we show how to transfer two state vectors and between hidden cells of RRNN and mimic the structure of LSTM. To adhere with notation from prior works, we use and to replace and in the above general definition. The transition equations and cell output are therefore
[TABLE]
where consists of several copies of and possible other constant vectors, and consists of several copies of and possible other constant vectors.
Appendix C Expressibility of RRNN
We extend the contect of Section 5 here. We first show that for a given set of vectors, there always exists a scoring function that can rank the scores of these vectors by any order we want. Formally, we have the following lemma.
Lemma 1**.**
Given vectors , there exists a function with a set of parameters such that .
We next show that if we carefully choose sets , the quantity , and the scoring function , then Algorithm 1 can replicate the GRU and LSTM equations.
To replicate GRU, we should have , , , , where is the zero vector. We further set
- •
, where , and ,
- •
, where , and ,
- •
, where , and ,
- •
, where stands for the all-ones vector and stands for the identity mapping,
- •
, where is the entry-wise multiplication.
Theorem 1 therefore becomes the following
Theorem 5**.**
There exists a scoring function such that Algorithm 1 generates GRU equations (1) – (4) for the choice of , and specified above.
For LSTM, note that there are two state vectors and . Therefore, to replicate LSTM (see equations (7) – (11) below), we run Algorithm 1 twice. In the first run, we should have , , , . We further set
- •
, where , and ,
- •
, where , and ,
- •
, where , and ,
- •
,
- •
.
In the second run, we should have , , , . We further set , where , , where , , and . Theorem 2 therefore becomes the following
Theorem 6**.**
There exists a scoring function such that Algorithm 1 (applied twice) generates the following LSTM equations
[TABLE]
for the choice of , and specified above.
C.1 Proof of Lemma 1
Consider function
[TABLE]
with , and is a large enough constant such that , and .
For , since , we have
[TABLE]
On the other hand, for a fixed and all , we have , and therefore
[TABLE]
In conclusion, for , we have
[TABLE]
and thus .
C.2 Proof of Theorem 5 and 6
We start with the proof of Theorem 5. In Algorithm 1, we set , , , , where is the zero vector. In the following, “the algorithm” refers to Algorithm 1. The scoring function has a set of parameters and is capable of sorting the scores of different vectors. We show the existence of this function at the end of the proof by relying on Lemma 1.
We start with . For , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and . Similarly, the algorithm finds to be the vector with the highest score in the set . We have and .
For , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and .
For , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and .
For , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and .
For , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and . Similarly, the algorithm finds to be the vector with the highest score in the set . Thus we have and
Finally, for , the algorithm generates the vector set and one of its elements is . The scoring function guarantees that . Therefore, we have and .
It remains to specify the scoring function . Note that should satisfy that for . Since each set contains a finite number of vectors, Lemma 1 guarantees that such scoring function exists. Therefore, the algorithm returns vector and the binary tree rooted at as the output, and thus it replicates the GRU equations (1) – (4). ∎
The proof of Theorem 6 is almost the same as the proof above. The only difference is that in the first run of Algorithm 1, we generate equations (7) – (10), while in the second run of Algorithm 1, we generate equation (11).
Appendix D Gradient Control
In this section, we first give the full statements of Theorem 3 and 4. Then we give proofs for these two theorems and discuss about them.
Theorem 7** (Sufficient condition of gradient vanishing).**
Let to be the set of vectors on the nodes of predicted tree . Assume that there exist constants such that for all ,
[TABLE]
Under conditions (12) – (16), we have as , i.e., the vanishing gradient problem occurs.
Theorem 8** (Necessary condition of gradient exploding, restated).**
Let be the minimum possible depth of all full binary trees . If the exploding gradient problem occurs, then at least one of the following conditions hold:
- •
there exists an activation function such that ,
- •
there exists a parameter matrix such that ,
- •
for infinite many , there exists a pair of parent-child nodes in the tree such that , where ,
- •
for infinite many , there exists a pair of parent-child nodes in the tree such that , where .
D.1 Proof of Theorem 7
Recall that Algorithm 1 builds a full binary tree with internal nodes and leaf nodes for the -th hidden cell of the RRNN model. We use and to denote the internal nodes and leaf nodes of the tree , respectively. We denote to be the set of vectors on the predicted tree . We use and to denote the spectral norm of matrix and the infinity norm of vector , respectively. We use to denote the diagonalization of vector . For an activation function , we use to denote the derivative of .
Note that
[TABLE]
Intuitively, the vanishing gradients problem appears when the norm of is smaller than 1. We first provide some lemmas that facilitate proving Theorem 3. For simplicity, we remove the subscript in and , since the following derivation applies to all in the same way.
We define the path starting from the root node to a leaf node by P^{k}=\big{[}P_{0}^{k},P_{1}^{k},\ldots,P_{l_{k}}^{k}\big{]}, where is the length of this path, , and . Lemma 2 gives an upper-bound for the norm of the gradient of a node with respect to one of its child node in the binary tree .
Lemma 2**.**
Under conditions (12) – (15), there exists a constant such that for all and .
Proof.
For simplicity, we write , where is the index in and , , , and is the other child node of . The case where is similar.
By the chain rule, we have
[TABLE]
where the last inequality follows by by condition (14) together with conditions (12) and (13). By setting , the statement holds from condition (16). ∎
We have for all ,
[TABLE]
where the last inequality follows by Lemma 2.
Note that are the lengths of all the paths starting from the root node to the leaf node of a full binary tree. Lemma 3 gives an upper-bound of the sum of exponents of these lengths.
Lemma 3**.**
Suppose are the lengths of the paths of the full binary tree . Then for any , there exists a constant , such that
[TABLE]
Proof.
We prove by induction on that
[TABLE]
For , the tree has exactly one internal node and two leaf nodes, thus there is only one tree structure for if we do not consider isomorphisms. We have and .
Suppose that equation (18) holds for , and we consider the case of . For a tree , recall the definition of in Section 3.3. Given the full binary tree , we denote to be the node that has the largest index in among all internal nodes of . It is obvious that both child nodes of are leaf nodes (if not, say the left child of is also an internal nodes, then it should have a larger index than , which leads to a contradiction). We use to denote the tree obtained by removing the two child nodes of from the tree ( is a leaf node of ). Then has exactly internal nodes. We use and to denote the lengths of all paths of and , respectively. Without loss of generality, we denote the length of the path that ends at in as , and the length of those two paths that pass through in as and , respectively.
Note that and . We have
[TABLE]
where the inequality follows from the induction equation and the facts that and . This complete the induction step.
It remains to define the constant . Since , we have
[TABLE]
Taking finishes the proof for Lemma 3. ∎
By (17) and Lemma 3, for every we have
[TABLE]
Combining with condition (15), we have
[TABLE]
As , we have goes to 0 exponentially with . ∎
D.2 Disscussion of Theorem 3
We next discuss the feasibility of conditions (12) – (16). Condition (12) requires all the weight matrices in to have the spectral norm no larger than . For sigmoid, condition (13) holds for while for tanh and ReLU it holds for . Condition (14) bounds the spectral norm of the gradient of each binary function. If the binary operation is addition, then the Jacobian matrix is simply the identity matrix and its spectral norm equals to 1. For vector entry-wise multiplication, note that
[TABLE]
where is the upper bound of the infinity norm of all vectors on the predicted trees. Therefore, if , we should have . Condition (16) holds when the scale of weight matrices or vectors on nodes of the predicted trees are small. In the experiments we have and . Note also that if each is the outcome of sigmoid or tanh, or entry-wise product of such vectors; in presence of addition this no longer holds however computational experiments have established that even if addition is a candidate binary operation. Then condition (16) holds for which has been observed in our experiments.
It is worth to mention that condition (15) is mild since we only require the norm to be bounded by a sufficiently large constant. By (6), we have
[TABLE]
There are three terms in the expression of that are related to , namely, the standard loss term, the tree distance term, and the scoring margin term. We bound them one by one. Since the number of samples is finite, we only consider each term for one data point in the following (i.e. we ignore the expectation).
Assume that hold. Then the loss term is bounded by
[TABLE]
If we use to denote the vector of the root node of the ground truth tree and assume that for all . Note that only appears at the root node of the predicted tree , and the definition of TD can be regarded as a summation over many norms of vector differences. Then the only term in TD that includes is . Therefore, the tree distance term is bounded by
[TABLE]
Again, note that only appears in the term
[TABLE]
If we assume that holds for any vector , then the scoring margin term is bounded by
[TABLE]
In conclusion, if we assume the existence of constants , and , then the gradient of loss function with respect to the hidden state is bounded. Note that in practice and are about the norm of a finite set of vectors, and bound the norm of some simple functions or networks which in practice are all bounded. Therefore, we can easily argue that these constants do exist and thus the condition (15) is mild.
In summary, gradient vanishing frequently appears in practice.
D.3 Discussion of Theorem 8
In this section, we discuss the conditions appearing in the Theorem 8. As the proof is similar to the proof of Theorem 3 we omit it here.
The conditions listed in Theorem 8 are common in practice since the quantity is smaller than 1. If we have or , then the first condition above is automatically achieved. Besides, if the addition operation belongs to , then the third and the fourth conditions are both fulfilled. In summary, gradient exploding is frequent in practice.
Appendix E Details of Experimental Study
E.1 Implementation Details
For our implementation of RRNN-GRU, we use PyTorch and train on Nvidia 1080 Ti GPUs or Intel Skylake CPUs. In order for our choices of cell structures to be differentiable with respect to the parameters of the scoring network, we evaluate softmax over the scores of all potential vectors at each node in the cell. Gradient clipping is used for RRNN-GRU, but random hyperparameter search often allows large gradient magnitudes. With the optimal hyperparameters, training of RRNN-GRU takes approximately ten hours for the Wikipedia dataset, one hour for PTB, and eight hours for SST, which is longer than the GRU training time since the RRNN-GRU weights must adapt to multiple placements within the cell structure.
For the RRNN model, we use batch normalization to stabilize training. The RRNN training time on the Wikipedia dataset with 5,000 samples is 40 hours on a CPU of a 12-core server. We find RRNN to be faster on a CPU than GPU due to its structure searching algorithm, but RRNN-GRU’s algorithm runs faster on GPUs.
E.2 Hyperparameters
GRU on Wiki-5k: batch size of 18, learning rate of , and -regularization coefficient of . 2. 2.
RRNN on Wiki-5k: batch size of 16, learning rate of , and scoring network hidden size of 256. . 3. 3.
GRU on Wiki-10k: batch size of 41, learning rate of , and -regularization coefficient of . 4. 4.
RRNN-GRU on Wiki-10k: batch size of 128, learning rate of , and scoring network hidden size of 64. Training alternates between the , and weights and the scoring network every five epochs. . Gradients are clipped to the maximum norm of 1. 5. 5.
GRU on SST: learning rate of , batch size of 3, and weight decay coefficient of . 6. 6.
RRNN-GRU on SST: learning rate of , , max-margin of , scoring network hidden size of 10 nodes, gradients clipped to the norm of 46.3, alternating training every epoch. 7. 7.
GRU on PTB: learning rate of , batch size of 6, and weight decay coefficient of . 8. 8.
RRNN-GRU on PTB: batch size of 116, learning rate of , , max scoring margin of 1.74, maximum gradient magnitude of 1.64, scoring hidden size of 137, and alternating training every epoch.
We next list the hyperparamter search ranges for RRNN-GRU in Table 2 and GRU in Table 3.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] Bowen Baker, Otkrist Gupta, Nikhil Naik, and Ramesh Raskar. Designing neural network architectures using reinforcement learning. In International Conference on Learning Representations (ICLR) , 2017.
- 2[2] Yoshua Bengio, Patrice Simard, and Paolo Frasconi. Learning long-term dependencies with gradient descent is difficult. IEEE Transactions on Neural Networks , 5(2):157–166, 1994.
- 3[3] Jonathon Cai, Richard Shin, and Dawn Song. Making neural programming architectures generalize via recursion. In International Conference on Learning Representations (ICLR) , 2017.
- 4[4] François Chollet. Xception: Deep learning with depthwise separable convolutions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) , pages 1251–1258, 2017.
- 5[5] Junyoung Chung, Caglar Gulcehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation of gated recurrent neural networks on sequence modeling. In Conference on Neural Information Processing Systems (NIPS) Workshop on Deep Learning , 2014.
- 6[6] Wim De Mulder, Steven Bethard, and Marie-Francine Moens. A survey on the application of recurrent neural networks to statistical language modeling. Computer Speech & Language , 30(1):61–98, 2015.
- 7[7] Thomas Elsken, Jan Hendrik Metzen, and Frank Hutter. Neural architecture search: A survey. ar Xiv preprint ar Xiv:1808.05377 , 2018.
- 8[8] Christoph Goller and Andreas Kuchler. Learning task-dependent distributed representations by backpropagation through structure. In Proceedings of International Conference on Neural Networks (ICNN) , pages 347–352, 1996.
