F RATERNAL
D ROPOUT
Anonymous authors
Paper under double-blind review
A BSTRACT
Recurrent neural networks (RNNs) form an important class of architectures among neural networks useful for language modeling and sequential prediction.
However, optimizing RNNs is known to be harder compared to feed-forward neural networks.
A number of techniques have been proposed in literature to address this problem.
In this paper we propose a simple technique called fraternal dropout that takes advantage of dropout to achieve this goal.
Speciﬁcally, we propose to train two identical copies of an RNN (that share parameters) with different dropout masks while minimizing the difference between their (pre-softmax) predictions.
In this way our regularization encourages the representations of RNNs to be invariant to dropout mask, thus being robust.
We show that our regularization term is upper bounded by the expectation-linear dropout objective which has been shown to address the gap due to the difference between the train and inference phases of dropout.
We evaluate our model and achieve state-of-the-art results in sequence modeling tasks on two benchmark datasets – Penn Treebank and Wikitext-2.
We also show that our approach leads to performance improvement by a signiﬁcant margin in image captioning (Microsoft COCO) and semi-supervised (CIFAR-10) tasks.
I NTRODUCTION
Recurrent neural networks (RNNs) like long short-term memory (LSTM; Hochreiter & Schmidhuber (1997)) networks and gated recurrent unit (GRU; Chung et al.
(2014)) are popular architectures for sequence modeling tasks like language generation, translation, speech synthesis, and machine comprehension.
However, they are harder to optimize compared to feed-forward networks due to challenges like variable length input sequences, repeated application of the same transition operator at each time step, and largely-dense embedding matrix that depends on the vocabulary size.
Due to these optimization challenges in RNNs, the application of batch normalization and its variants (layer normalization, recurrent batch normalization, recurrent normalization propagation) have not been as successful as their counterparts in feed-forward networks (Laurent et al., 2016), although they do considerably provide performance gains.
Similarly, naive application of dropout (Srivastava et al., 2014) has been shown to be ineffective in RNNs (Zaremba et al., 2014).
Therefore, regularization techniques for RNNs is an active area of research.
To address these challenges, Zaremba et al.
(2014) proposed to apply dropout only to the nonrecurrent connections in multi-layer RNNs.
Variational dropout (Gal & Ghahramani (2016)) uses the same dropout mask throughout a sequence during training.
DropConnect (Wan et al., 2013) applies the dropout operation on the weight matrices.
Zoneout (Krueger et al.
(2016)), in a similar spirit with dropout, randomly chooses to use the previous time step hidden state instead of using the current one.
Similarly as a substitute for batch normalization, layer normalization normalizes the hidden units within each sample to have zero mean and unit standard deviation.
Recurrent batch normalization applies batch normalization but with unshared mini-batch statistics for each time step (Cooijmans et al., 2016).
Merity et al.
(2017a)
and Merity et al.
(2017b) on the other hand show that activity regularization (AR) and temporal activation regularization (TAR) 1 are also effective methods for regularizing
LSTMs.
Another more recent way of regularizing RNNs, that is similar in spirit to the approach we take, involves minimizing the difference between the hidden states of the original and the auxiliary network Serdyuk et al.
In this paper we propose a simple regularization based on dropout that we call fraternal dropout , where we minimize an equally weighted sum of prediction losses from two identical copies of the same LSTM with different dropout masks, and add as a regularization the (cid:96) 2 difference between the predictions (pre-softmax) of the two networks.
We analytically show that our regularization objective is equivalent to minimizing the variance in predictions from different i.i.d.
dropout masks; thus encouraging the predictions to be invariant to dropout masks.
We also discuss how our regularization is related to expectation linear dropout Ma et al.
(2016), Π -model Laine & Aila (2016) and activity regularization Merity et al.
(2017b),
and empirically show that our method provides non-trivial gains over these related methods which we explain furthermore in our ablation study (section 5).
F RATERNAL DROPOUT
Dropout is a powerful regularization for neural networks.
It is usually more effective on densely connected layers because they suffer more from overﬁtting compared with convolution layers where the parameters are shared.
For this reason dropout is an important regularization for RNNs.
However, dropout has a gap between its training and inference phase since the latter phase assumes linear activations to correct for the factor by which the expected value of each activation would be different
Ma et al.
In addition, the prediction of models with dropout generally vary with different dropout mask.
However, the desirable property in such cases would be to have ﬁnal predictions be invariant to dropout masks.
As such, the idea behind fraternal dropout is to train a neural network model in a way that encourages the variance in predictions under different dropout masks to be as small as possible.
Specifically, consider we have an RNN model denoted by M ( θ ) that takes as input X , where θ denotes the model parameters.
Let p t ( z t , s ti ; θ ) ∈ R m be the prediction of the model for input sample X at time t , for dropout mask s ti and current input z t , where z t is a function of X and the hidden states corresponding to the previous time steps.
Similarly, let (cid:96) t ( p t ( z t , s ti ; θ ) , Y ) be the corresponding t th time step loss value for the overall input-target sample pair ( X , Y ) .
Then in fraternal dropout , we simultaneously feed-forward the input sample X through two identical copies of the RNN that share the same parameters θ but with different dropout masks s ti and s tj at each time step t .
This yields two loss values at each time step t given by (cid:96) t ( p t ( z t , s ti ; θ ) , Y ) , and (cid:96) t ( p t ( z t , s tj ; θ ) , Y ) .
Then the overall loss function of fraternal dropout is given by,
[Equation]
where κ is the regularization coefﬁcient, m is the dimensions of p t ( z t , s ti ; θ ) and R FD ( z t ; θ ) is the fraternal dropout regularization given by,
[Equation]
We use Monte Carlo sampling to approximate R FD ( z t ; θ ) where p t ( z t , s ti ; θ ) and p t ( z t , s tj ; θ ) are the same as the one used to calculate (cid:96) t values.
Hence, the additional computation is negligible.
We note that the regularization term of our objective is equivalent to minimizing the variance in the prediction function with different dropout masks as shown below (proof in Appendix).
Remark 1.
Let s ti and s tj be i.i.d.
dropout masks and p t ( z t , s ti ; θ
) ∈ R m be the prediction function as described above.
Then,
[Equation]
Note that a generalization of our approach would be to minimize the difference between the predictions of the two networks with different data/model augmentations.
In this paper we focus on using different dropout masks.
R ELATED W ORK 3. R ELATION TO E XPECTATION L INEAR D ROPOUT (ELD)
Ma et al.
(2016) analytically showed that the expected error (over samples) between a model’s expected prediction over all dropout masks, and the prediction using the average mask, is upper bounded.
Based on this result, they propose to explicitly minimize the difference (we have adapted their regularization to our notations),
[Equation]
where s is the dropout mask.
However, due to feasibility consideration, they instead propose to use the following regularization in practice,
[Equation]
Speciﬁcally, this is achieved by feed-forwarding the input twice through the network, with and without dropout mask, and minimizing the main network loss (with dropout) along with the regularization term speciﬁed above (but without back-propagating the gradients through the network without dropout).
The goal of Ma et al.
(2016) is to minimize the network loss along with the expected difference between the prediction from individual dropout mask and the prediction from the expected dropout mask.
We note that our regularization objective is upper bounded by the expectation-linear dropout regularization as shown below (proof in Appendix).
Proposition
[Equation]
This result shows that minimizing the ELD objective indirectly minimizes our regularization term.
Finally as indicated above, they apply the target loss only on the network with dropout.
In fact, in our own ablation studies (see section 5)
we ﬁnd that back-propagating target loss through the network (without dropout) makes optimizing the model harder.
However, in our setting, simultaneously backpropagating target loss through both networks yields both performance gain as well as convergence gain.
We believe convergence is faster for our regularization because network weights are more likely to get target based updates from back-propagation in our case.
This is especially true for weight dropout (Wan et al., 2013) since in this case dropped weights do not get updated in the training iteration.
3. R ELATION TO Π - MODEL
Laine & Aila (2016) propose Π -model with the goal of improving performance on classiﬁcation tasks in the semi-supervised setting.
They propose a model similar to ours (considering the equivalent deep feed-forward version of our model) except they apply target loss only on one of the networks and use time-dependent weighting function ω ( t ) (while we use constant κmT ).
The intuition in their case is to leverage unlabeled data by using them to minimize the difference in prediction between the two copies of the network with different dropout masks.
Further, they also test their model in the supervised setting but fail to explain the improvements they obtain by using this regularization.
We note that in our case we analytically show that minimizing our regularizer (also used in Π -model) is equivalent to minimizing the variance in the model predictions (remark 1).
Furthermore, we also show the relation of our regularizer to expectation linear dropout (proposition 1).
In section 5, we study the effects of target based loss on both networks, which is not used in the Π -model.
We ﬁnd that applying target loss on both the networks leads to signiﬁcantly faster convergence.
Finally, we bring to attention that temporal embedding (another model proposed by Laine & Aila (2016), claimed to be a better version of Π -model for semi-supervised, learning) is intractable in natural language processing applications because storing averaged predictions over all of the time steps would be memory exhaustive (since predictions are usually huge - tens of thousands values).
On a ﬁnal note, we argue that in the supervised case, using a time-dependent weighting function ω ( t ) instead of a constant value κmT is not needed.
Since the ground truth labels are known, we have not observed the problem mentioned by Laine & Aila (2016), that the network gets stuck in a degenerate solution when ω ( t ) is too large in earlier epochs of training.
We note that it is much easier to search for an optimal constant value, which is true in our case, as opposed to tuning the time-dependent function.
[Table]
[Table] [Table]
Gal & Ghahramani (2016)
[Table]
Gal & Ghahramani (2016) -
[Table]
Inan
[Table] [Table]
Inan
[Table] [Table]
[Table]
Melis
[Table] [Table]
Melis et al
[Table] [Table]
Merity et al.
[Table]
2017a)
[Table]
Fraternal dropout
[Table] [Table]
Merity
[Table]
Inan
[Table]
Melis
[Table] [Table]
Melis et al.
[Table] [Table]
[Table]
Melis et al.
(2017) - 2-layer skip connection LSTM
[Table] [Table]
Similarity to Π -model makes our method related to other semi-supervised works, mainly Rasmus et al.
and Sajjadi et al.
Since semi-supervised learning is not a primary focus of this paper, we refer to Laine & Aila (2016) for more details.
E XPERIMENTS 4. L ANGUAGE M ODELS
In the case of language modeling we test our model 2 on two benchmark datasets – Penn Tree-bank (PTB) dataset (Marcus et al., 1993) and WikiText-2 (WT2) dataset (Merity et al., 2016).
We use preprocessing as speciﬁed by Mikolov et al.
(2010) (for PTB corpus) and Moses tokenizer Koehn et al.
(2007) (for the WT2 dataset).
For both datasets we use the AWD-LSTM 3-layer architecture described in Merity et al.
(2017a) 3 .
The number of parameters in the model used for PTB is 24 million as compared to 34 million in the case of WT2 because WT2 has a larger vocabulary size for which we use a larger embedding matrix.
Apart from those differences, the architectures are identical.
Word level Penn Treebank (PTB)
We evaluate our model using the perplexity metric and compare the results that we obtain against the existing state-of-the-art results.
The results are reported in Table 1.
Our approach achieves the state-of-the-art performance compared with existing benchmarks.
Word level WikiText-
In the case of WikiText-2 language modeling task, we outperform the current state-of-the-art by a signiﬁcant margin.
The ﬁnal results are presented in Table 2.
More details about the experiment may be found in the subsection 5.
[Table]
4. I MAGE CAPTIONING
We also apply fraternal dropout on an image captioning task.
We use the well-known show and tell model as a baseline 4 (Vinyals et al., 2014).
We emphasize that in the image captioning task, the image encoder and sentence decoder architectures are usually learned together.
Since we want to focus on the beneﬁts of using fraternal dropout in RNNs we use frozen pretrained ResNet-101 (He et al., 2015) model as our image encoder.
It means that our results are not directly comparable with other state-of-the-art methods, however we report results for the original methods so readers can see that our baseline performs well.
The ﬁnal results are presented in Table 3.
We argue that in this task smaller κ values are optimal because the image captioning encoder is given all information in the beginning and hence the variance of consecutive predictions is smaller that in unconditioned natural language processing tasks.
Fraternal dropout may beneﬁts here mainly due to averaging gradients for different mask and hence updating weights more frequently.
A BLATION S TUDIES
In this section, the goal is to study existing methods closely related to ours – expectation linear dropout Ma et al.
(2016), Π -model Laine & Aila (2016) and activity regularization Merity et al.
(2017b).
All of our experiments for ablation studies, which apply a single layer LSTM, use the same hyper-parameters and model architecture 5 as Melis et al.
5. E XPECTATION - LINEAR DROPOUT (ELD)
The relation with expectation-linear dropout Ma et al.
(2016) has been discussed in the section 2.
Here we perform experiments to study the difference in performance when using the ELD regularization versus our regularization (FD).
In addition to ELD, we also study a modiﬁcation (ELDM) of ELD which applies target loss to both copies of LSTMs in ELD similar to FD (notice in their case they only have dropout on one LSTM).
Finally we also evaluate a baseline model without any of these regularizations.
The learning dynamics curves are shown in Figure 1.
Our regularization performs better in terms of convergence compared with other methods.
In terms of generalization, we ﬁnd that FD is similar to ELD, but baseline and ELDM are much worse.
Interestingly, looking at the train and validation curves together, ELDM seems to be suffering from optimization problems.
5. Π - MODEL
Since Π -model Laine & Aila (2016) is similar to our algorithm (even though it is designed for semi-supervised learning in feed-forward networks), we study the difference in performance with
[Figure]
Π -model 6 both qualitatively and quantitatively to establish the advantage of our approach.
First, we run both single layer LSTM and 3-layer AWD-LSTM on PTB task to check how their model compares with ours in the case of language modeling.
The results are shown in Figure 1 and 2.
We ﬁnd that our model converges signiﬁcantly faster than Π -model.
We believe this happens because we back-propagate the target loss through both networks (in contrast to Π -model) that leads to weights getting updated using target-based gradients more often.
Even though we designed our algorithm speciﬁcally to address problems in RNNs to have a fair comparison, we compare with Π -model on a semi-supervised task which is their goal.
Speciﬁcally, we use the CIFAR-10 dataset that consists of 32 × 32 images from 10 classes.
Following the usual splits used in semi-supervised learning literature, we use 4 thousand labeled and 41 thousand unlabeled samples for training, 5 thousand labeled samples for validation and 10 thousand labeled samples for test set.
We use the original ResNet-56 (He et al., 2015) architecture.
We run grid search on κ ∈ { 0 . 05 , 0 . 1 , 0 . 15 , 0 . 2 } , dropout rates in
15 , 0 . 2 } and leave the rest of the hyperparameters unchanged.
We additionally check importance of using unlabeled data.
The results are reported in Table 4.
We ﬁnd that our algorithm performs at par with Π -model.
When unlabeled data is not used, fraternal dropout provides slightly better results as compared to traditional dropout.
[Table]
5. A CTIVITY REGULARIZATION AND TEMPORAL ACTIVITY REGULARIZATION ANALYSIS
The authors of Merity et al.
(2017b) study the importance of activity regularization (AR) 7 and temporal activity regularization (TAR) in LSTMs given as,
[Equation] [Equation]
(7) where h t ∈ R
d is the LSTM’s output activation at time step t (hence depends on both current input z t and the model parameters θ ).
Notice that AR and TAR regularizations are applied on the output of the LSTM, while our regularization is applied on the pre-softmax output p t ( z t , s ti ; θ ) of the LSTM.
However, since our regularization can be decomposed as
[Equation]
and encapsulates an (cid:96) 2 term along with the dot product term, we perform experiments to conﬁrm that the gains in our approach is not due to the (cid:96) 2 regularization alone.
A similar argument goes for the TAR objective.
We run a grid search on α ∈ { 1 , 2 , . . .
, 12 } , β ∈ { 1 , 2 , . .
, 12 } , which include the hyper-parameters mentioned in Merity et al.
(2017a).
For our regularization, we use κ ∈ { 0 . 05 , 0 . 1 , . . .
Furthermore, we also compare with a regularization (PR) that regularizes (cid:107) p t ( z t , s ti ; θ ) (cid:107) 22 to further rule-out any gains only from (cid:96) 2 regularization.
Based on this grid search, we pick the best model on the validation set for all the regularizations, and additionally report a baseline model without any of these four mentioned regularizations.
The learning dynamics is shown in Figure 4.
Our regularization performs better both in terms of convergence and generalization compared with other methods.
Average hidden state activation is reduced when any of the regularizer described is applied (see Figure 3).
5. L ANGUAGE MODELING FAIR COMPARISON
As mentioned in the subsection 4.1, inﬂuenced by Melis et al.
(2017), we want to make sure that fraternal dropout outperform existing methods not simply because of extensive hyper-parameter grid search.
Hence, in our experiments we left a vast majority of hyper-parameters mentioned in the original paper unchanged i.e. embedding and hidden states sizes, gradient clipping value, weight decay and the values used for all dropout layers (dropout on the word vectors, the output between
LSTM layers, the output of the ﬁnal LSTM, and embedding dropout).
However, a few changes were necessary:
• the coefﬁcients for AR and TAR have to be altered because fraternal dropout also affects RNNs activation (as explained in the subsection 5.3) – we have not run grid search to obtain the best values but simply deactivated AR and TAR regularizers;
[Table]
• since we need twice as much memory, the batch size is halved so the model needs approximately the same amount of memory and hence ﬁts on the same GPU.
The last change in hyper-parameters is to alter the non-monotone interval n used in ASGD optimizer.
We run a grid search on n ∈ { 5 , 25 , 40 , 50 , 60 } and obtain very similar results for the largest values (40, 50 and 60) in the candidate set.
Hence, our model is trained longer using ordinary SGD optimizer as compared to the original model.
To double check that we do not obtain trivial gains, we run ten learning procedures for the original hyper-parameters with different seeds (without ﬁne-tuning) for PTB dataset to compute conﬁdence intervals.
The average best validation perplexity is 60 .
64 ± 0 .
15 with the minimum value equals 60 .
The same for test perplexity is 58 .
32 ± 0 .
14 and 58 .
05 , respectively.
Our score ( 59 . 8 validation and 58 .
test perplexity) beats ordinal dropout minimum values.
Due to lack of computational power, we run a single training procedure for fraternal dropout on
WT2 dataset.
In this experiment, we use the best hyper-parameters found for PTB dataset ( κ = 0 .
1 , non-monotone interval n = 60 and halved batch size).
We conﬁrm that ASGD beneﬁts when the ﬁne-tuning step is used (Merity et al., 2017a).
However, this is a very time-consuming practice and since different hyper-parameters may be used in this additional part of the learning procedure, the probability of obtaining better results due to the extensive grid search is higher.
Hence, in our experiments we use the same ﬁne-tuning procedure as implemented in the ofﬁcial repository (even fraternal dropout was not used).
We present the importance of ﬁne-tuning in Table 5.
We argue that running grid search for all hyper-parameters jointly may lead to better results (altering dropout rates may be especially beneﬁcial since our method explicitly takes advantage of using dropout).
However, our goal here is to rule out the possibility of outperforming just because of using better hyper-parameters.
C ONCLUSION
In this paper we propose a simple regularization method for RNNs called fraternal dropout that acts as a regularization by reducing the variance in model predictions across different dropout masks.
We show that our model achieves state-of-the-art results on benchmark language modeling tasks along with faster convergence.
We also analytically study the relationship between our regularization and expectation linear dropout Ma et al.
We perform a number of ablation studies to evaluate our model from different aspects and carefully compare it with related methods both qualitatively and quantitatively
A PPENDIX
Remark 1.
Let s ti and s tj be i.i
[Equation]
d. dropout masks and p t ( z t , s ti ; θ
) ∈ R m be the prediction function as described above.
Then,
[Equation]
Proof.
For simplicity of notation
[Equation]
we omit the time index t .
[Equation]
Proposition 1.
R FD ( z t ; θ ) ≤ 4 ˜ R ELD ( z t ; θ ) .
Proof.
Let ¯ s :=
E s [ s ]
[Equation]
then
[Equation]
Then using Jensen’s inequality,
[Equation] [Equation]