Paper:
Scalable Bayesian Learning of Recurrent Neural Networks for Language Modeling
Recurrent neural networks (RNNs) have shown promising performance for language modeling. However, traditional training of RNNs using back-propagation through time often suffers from overfitting. One reason for this is that stochastic optimization (used for large training sets) does not provide good estimates of model uncertainty. This paper leverages recent advances in stochastic gradient Markov Chain Monte Carlo (also appropriate for large training sets) to learn weight uncertainty in RNNs. It yields a principled Bayesian learning algorithm, adding gradient noise during training (enhancing exploration of the model-parameter space) and model averaging when testing. Extensive experiments on various RNN models and across a broad range of applications demonstrate the superiority of the proposed approach relative to stochastic optimization.
1 Introduction
Language modeling is a fundamental task, used for example to predict the next word or character in a text sequence given the context. Recently, recurrent neural networks (RNNs) have shown promising performance on this task (Mikolov et al., 2010; Sutskever et al., 2011). RNNs with Long Short-Term Memory (LSTM) units (Hochreiter and Schmidhuber, 1997) have emerged as a popular architecture, due to their representational power and effectiveness at capturing long-term dependencies.
RNNs are usually trained via back-propagation through time (Werbos, 1990), using stochastic optimization methods such as stochastic gradient de-
scent (SGD) (Robbins and Monro, 1951); stochastic methods of this type are particularly important for training with large data sets. However, this approach often provides a maximum a posteriori (MAP) estimate of model parameters. The MAP solution is a single point estimate, ignoring weight uncertainty (Blundell et al., 2015; HernándezLobato and Adams, 2015). Natural language often exhibits significant variability, and hence such a point estimate may make over-confident predictions on test data.
To alleviate overfitting RNNs, good regularization is known as a key factor to successful applications. In the neural network literature, Bayesian learning has been proposed as a principled method to impose regularization and incorporate model uncertainty (MacKay, 1992; Neal, 1995), by imposing prior distributions on model parameters. Due to the intractability of posterior distributions in neural networks, Hamiltonian Monte Carlo (HMC) (Neal, 1995) has been used to provide sample-based approximations to the true posterior. Despite the elegant theoretical property of asymptotic convergence to the true posterior, HMC and other conventional Markov Chain Monte Carlo methods are not scalable to large training sets.
This paper seeks to scale up Bayesian learning of RNNs to meet the challenge of the increasing amount of “big” sequential data in natural language processing, leveraging recent advances in stochastic gradient Markov Chain Monte Carlo (SG-MCMC) algorithms (Welling and Teh, 2011; Chen et al., 2014; Ding et al., 2014; Li et al., 2016a). Specifically, instead of training a single network, SG-MCMC is employed to train an ensemble of networks, where each network has its parameters drawn from a shared posterior distribution. This is implemented by adding additional gradient noise during training and utilizing model
2
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
Encoding weights
Recurrent weights
Decoding weights
Output
Input
Hidden
Figure 1: Illustration of different weight learning strategies in a single-hidden-layer RNN. Stochastic optimization used for MAP estimation puts fixed values on all weights. Naive dropout is allowed to put weight uncertainty only on encoding and decoding weights, and fixed values on recurrent weights. The proposed SG-MCMC scheme imposes distributions on all weights.
averaging when testing. This simple procedure has the following salutary properties for training neural networks: (i) When training, the injected noise encourages model-parameter trajectories to better explore the parameter space. This procedure was also empirically found effective in (Neelakantan et al., 2016). (ii) Model averaging when testing alleviates overfitting and hence improves generalization, transferring uncertainty in the learned model parameters to subsequent prediction. (iii) In theory, both asymptotic and non-asymptotic consistency properties of SG-MCMC methods in posterior estimation have been recently established to guarantee convergence (Chen et al., 2015a; Teh et al., 2016). (iv) SG-MCMC is scalable; it shares the same level of computational cost as SGD in training, by only requiring the evaluation of gradients on a small mini-batch. To the authors’ knowledge, RNN training using SG-MCMC has not been investigated previously, and is a contribution of this paper. We also perform extensive experiments on several natural language processing tasks, demonstrating the effectiveness of SG-MCMC for RNNs, including character/word-level language modeling, image captioning and sentence classification.
2 Related Work
Several scalable Bayesian learning methods have been proposed recently for neural networks. These come in two broad categories: stochastic variational inference (Graves, 2011; Blundell et al., 2015; Hernández-Lobato and Adams, 2015) and SG-MCMC methods (Korattikara et al., 2015; Li et al., 2016a). While prior work focuses on feed-forward neural networks, there has been little if any research reported for RNNs using SG-
MCMC.
Dropout (Hinton et al., 2012; Srivastava et al., 2014) is a commonly used regularization method for training neural networks. Recently, several works have studied how to apply dropout to RNNs (Pachitariu and Sahani, 2013; Bayer et al., 2013; Pham et al., 2014; Zaremba et al., 2014; Bluche et al., 2015; Moon et al., 2015; Semeniuta et al., 2016; Gal and Ghahramani, 2016b). Among them, naive dropout (Zaremba et al., 2014) can impose weight uncertainty only on encoding weights (those that connect input to hidden units) and decoding weights (those that connect hidden units to output), but not the recurrent weights (those that connect consecutive hidden states). It has been concluded that noise added in the recurrent connections leads to model instabilities, hence disrupting the RNN’s ability to model sequences.
Dropout has been recently shown to be a variational approximation technique in Bayesian learning (Gal and Ghahramani, 2016a; Kingma et al., 2015). Based on this, (Gal and Ghahramani, 2016b) proposed a new variant of dropout that can be successfully applied to recurrent layers, where the same dropout masks are shared along time for encoding, decoding and recurrent weights, respectively. Alternatively, we focus on SG-MCMC, which can be viewed as the Bayesian interpretation of dropout from the perspective of posterior sampling (Li et al., 2016b); this also allows imposition of model uncertainty on recurrent layers, enhancing performance. A comparison of naive dropout and SG-MCMC is illustrated in Fig. 1.
3 Recurrent Neural Networks
3.1 RNN as Bayesian Predictive Models
Consider data D = {D1, · · · ,DN}, where Dn , (Xn,Yn), with input Xn and output Yn. Our goal is to learn model parameters θ to best characterize the relationship from Xn to Yn, with corresponding data likelihood p(D|θ) =∏N n=1 p(Dn|θ). In Bayesian statistics, one sets a prior on θ via distribution p(θ). The posterior p(θ|D) ∝ p(θ)p(D|θ) reflects the belief concerning the model parameter distribution after observing the data. Given a test input X̃ (with missing output Ỹ), the uncertainty learned in training is transferred to prediction, yielding the posterior
3
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
predictive distribution:
p(Ỹ|X̃,D)= ∫ θ p(Ỹ|X̃,θ)p(θ|D)dθ . (1)
When the input is a sequence, RNNs may be used to parameterize the input-output relationship. Specifically, consider input sequence X = {x1, . . . ,xT }, where xt is the input data vector at time t. There is a corresponding hidden state vector ht at each time t, obtained by recursively applying the transition function ht = H(ht−1,xt) (specified in Section 3.2; see Fig. 1). The ouput Y differs depending on the application: a sequence {y1, . . . ,yT } in language modeling or a discrete label in sentence classification. In RNNs the corresponding decoding function is p(y|h), described in Section 3.3.
3.2 RNN Architectures
The transition function H(·) can be implemented with a gated activation function, such as Long Short-Term Memory (LSTM) (Hochreiter and Schmidhuber, 1997) or a Gated Recurrent Unit (GRU) (Cho et al., 2014). Both the LSTM and GRU have been proposed to address the issue of learning long-term sequential dependencies.
Long Short-Term Memory The LSTM architecture addresses the problem of learning longterm dependencies by introducing a memory cell, that is able to preserve the state over long periods of time. Specifically, each LSTM unit has a cell containing a state ct at time t. This cell can be viewed as a memory unit. Reading or writing the cell is controlled through sigmoid gates: input gate it, forget gate ft, and output gate ot. The hidden units ht are updated as
it = σ(Wixt +Uiht−1 + bi) ,
ft = σ(Wfxt +Ufht−1 + bf ) ,
ot = σ(Woxt +Uoht−1 + bo) ,
c̃t = tanh(Wcxt +Ucht−1 + bc) ,
ct = ft ct−1 + it c̃t , ht = ot tanh(ct) ,
where σ(·) denotes the logistic sigmoid function, and represents the element-wise matrix multiplication operator. W{i,f,o,c} are encoding weights, and U{i,f,o,c} are recurrent weights, as shown in Fig. 1. b{i,f,o,c} are bias terms.
Variants Similar to the LSTM unit, the GRU also has gating units that modulate the flow of information inside the hidden unit. It has been shown that a GRU can achieve similar performance to an LSTM in sequence modeling (Chung et al., 2014). We specify the GRU in the Supplementary Material.
The LSTM can be extended to the bidirectional LSTM and multilayer LSTM. A bidirectional LSTM consists of two LSTMs that are run in parallel: one on the input sequence and the other on the reverse of the input sequence. At each time step, the hidden state of the bidirectional LSTM is the concatenation of the forward and backward hidden states. In multilayer LSTMs, the hidden state of an LSTM unit in layer ` is used as input to the LSTM unit in layer `+1 at the same time step.
3.3 Applications
The proposed Bayesian framework can be applied to any RNN model; we focus on the following tasks to demonstrate the ideas.
Language Modeling In word-level language modeling, the input to the network is a sequence of words, and the network is trained to predict the next word in the sequence with a softmax classifier. Specifically, for a length-T sequence, denote yt = xt+1 for t = 1, . . . , T − 1. x1 and yT are always set to a special START and END token, respectively. At each time t, there is a decoding function p(yt|ht) = softmax(Vht) to compute the distribution over words, where V are the decoding weights (the number of rows of V corresponds to the number of words/characters). We also extend this basic language model to consider other applications: (i) a character-level language model can be specified in a similar manner by replacing words with characters (Karpathy et al., 2016). (ii) Image captioning can be considered as a conditional language modeling problem, in which we learn a generative language model of the caption conditioned on an image (Vinyals et al., 2015).
Sentence Classification Sentence classification aims to assign a semantic category label y to a whole sentence X. This is usually implemented through applying the decoding function once at the end of sequence: p(y|hT ) = softmax(VhT ), where the final hidden state of a RNN hT is often considered as the summary of the sentence (here
4
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
the number of rows of V corresponds to the number of classes).
4 Scalable Learning with SG-MCMC
4.1 The Pitfall of Stochastic Optimization
Typically there is no closed-form solution for the posterior p(θ|D), and traditional Markov Chain Monte Carlo (MCMC) methods (Neal, 1995) scale poorly for largeN . To ease the computational burden, stochastic optimization is often employed to find the MAP solution. This is equivalent to minimizing an objective of regularized loss function U(θ) that corresponds to a (non-convex) model of interest: θMAP = argminU(θ), U(θ) = − log p(θ|D). The expectation in (1) is approximated as:
p(Ỹ|X̃,D)= p(Ỹ|X̃,θMAP) . (2)
Though simple and effective, this procedure largely loses the benefit of the Bayesian approach, because the uncertainty on weights is ignored. To more accurately approximate (1), we employ stochastic gradient (SG) MCMC (Welling and Teh, 2011).
4.2 Large-scale Bayesian Learning
The negative log-posterior is
U(θ) , − log p(θ)− N∑ n=1 log p(Dn|θ). (3)
In optimization,E = − ∑N
n=1 log p(Dn|θ) is typically referred to as the loss function, and R ∝ − log p(θ) as a regularizer.
For large N , stochastic approximations are often employed:
Ũt(θ),− log p(θ)− N
M M∑ m=1 log p(Dim |θ), (4)
where Sm = {i1, · · · , iM} is a random subset of the set {1, 2, · · · , N}, with M N . The gradient on this mini-batch is denoted as f̃t = ∇Ũt(θ), which is an unbiased estimate of the true gradient. The evaluation of (4) is cheap even when N is large, allowing one to efficiently collect a sufficient number of samples in large-scale Bayesian learning, {θs}Ss=1, where S is the number of samples (this will be specified later). These samples are used to construct a sample-based estimation to the expectation in (1):
The finite-time estimation errors of SG-MCMC methods are bounded (Chen et al., 2015a), which guarantees (5) is an unbiased estimate of (1) asymptotically under appropriate decreasing stepsizes.
4.3 SG-MCMC Algorithms
SG-MCMC and stochastic optimization are parallel lines of work, designed for different purposes; their relationship has recently been revealed in the context of deep learning. The most basic SG-MCMC algorithm has been applied to Langevin dynamics, and is termed SGLD (Welling and Teh, 2011). To help convergence, a momentum term has been introduced in SGHMC (Chen et al., 2014), a “thermostat” has been devised in SGNHT (Ding et al., 2014) and preconditioners have been employed in pSGLD (Li et al., 2016a). These SG-MCMC algorithms often share similar characteristics with their counterpart approaches from the optimization literature such as the momentum SGD, Santa (Chen et al., 2016) and RMSprop/Adagrad (Tieleman and Hinton, 2012; Duchi et al., 2011). The interrelationships between SG-MCMC and optimization-based approaches are summarized in Table 1.
SGLD Stochastic Gradient Langevin Dynamics (SGLD) (Welling and Teh, 2011) draws posterior samples, with updates
θt = θt−1 − ηtf̃t−1 + √ 2ηtξt , (6)
where ηt is the learning rate, and ξt ∼ N (0, Ip) is a standard Gaussian random vector. SGLD is the SG-MCMC analog to stochastic gradient descent (SGD), whose parameter updates are given by:
θt = θt−1 − ηtf̃t−1 . (7)
SGD is guaranteed to converge to a local minimum under mild conditions (Bottou, 2010). The
5
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
Algorithm 1: pSGLD Input: Default hyperparameter settings:
ηt = 1×10−3, λ = 10−8, β1 = 0.99. Initialize: v0 ← 0, θ1 ∼ N (0, I) ; for t = 1, 2, . . . , T do
% Estimate gradient from minibatch St f̃t = ∇Ũt(θ); % Preconditioning vt ← β1vt−1 + (1− β1)f̃t f̃t;
G−1t ← diag ( 1 ( λ1+ v 1 2 t )) ;
% Parameter update ξt ∼ N (0, ηtG−1t ); θt+1← θt + ηt2 G −1 t f̃t+ ξt;
end
additional Gaussian term in SGLD helps the learning trajectory to explore the parameter space to approximate posterior samples, instead of obtaining a local minimum.
pSGLD Preconditioned SGLD (pSGLD) (Li et al., 2016a) was proposed recently to improve the mixing of SGLD. It utilizes magnitudes of recent gradients to construct a diagonal preconditioner to approximate the Fisher information matrix, and thus adjusts to the local geometry of parameter space by equalizing the gradients so that a constant stepsize is adequate for all dimensions. This is important for RNNs, whose parameter space often exhibits pathological curvature and saddle points (Pascanu et al., 2013), resulting in slow mixing. There are multiple choices of preconditioners; similar ideas in optimization include Adagrad (Duchi et al., 2011), Adam (Kingma and Ba, 2015) and RMSprop (Tieleman and Hinton, 2012). An efficient version of pSGLD, adopting RMSprop as the preconditioner G, is summarized in Algorithm 1, where denotes elementwise matrix division. When the preconditioner is fixed as the identity matrix, the method reduces to SGLD.
4.4 Understanding SG-MCMC
To further understand SG-MCMC, we show its close connection to dropout/dropConnect (Srivastava et al., 2014; Wan et al., 2013). These methods improve the generalization ability of deep models, by randomly adding binary/Gaussian noise to the local units or global weights. For neural networks with the nonlinear function q(·) and consecutive
layers h1 and h2, dropout and dropConnect are denoted as:
Dropout: h2 = ξ0 q(θh1), DropConnect: h2 = q((ξ0 θ)h1),
where the injected noise ξ0 can be binary-valued with dropping rate p or its equivalent Gaussian form (Wang and Manning, 2013):
Binary noise: ξ0 ∼ Ber(p),
Gaussian noise: ξ0 ∼ N (1, p
1− p ).
Note that ξ0 is defined as a vector for dropout, and a matrix for dropConnect. By combining dropConnect and Gaussian noise from the above, we have the update rule (Li et al., 2016b):
θt+1 = ξ0 θt − η
2 f̃t = θt −
η 2 f̃t + ξ ′ 0 , (8)
where ξ′0 ∼ N ( 0, p(1−p)diag(θ 2 t ) )
; (8) shows that dropout/ dropConnect and SGLD in (6) share the same form of update rule, with the distinction being that the level of injected noise is different. In practice, the noise injected by SGLD may not be enough. A better way that we find to improve the performance is to jointly apply SGLD and dropout. This method can be interpreted as using SGLD to sample the posterior distribution of a mixture of RNNs, with mixture probability controlled by the dropout rate.
5 Experiments
We present results on several tasks, including character/ word-level language modeling, image captioning, and sentence classification. The hyperparameter settings, the initialization of model parameters and model specifications on each dataset are provided in the Supplementary Material.
We do not perform any dataset-specific tuning other than early stopping on validation sets. When dropout is utilized, the dropout rate is set to 0.5. All experiments are implemented in Theano (Theano Development Team, 2016), using a NVIDIA GeForce GTX TITAN X GPU with 12GB memory.
5.1 Language Modeling
We first test character-level and word-level language modeling. The setup for each task is as follows.
6
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
• Following (Karpathy et al., 2016), we test character-level language modeling on the War and Peace (WP) novel. The training/validation/test sets contain 260/32/33 batches, in which there are 100 characters. The vocabulary size is 87, and we consider a 2-hidden-layer RNN of dimension 128.
• The Penn Treebank (PTB) corpus (Marcus et al., 1993) is used for word-level language modeling. The dataset adopts the standard split (929K training words, 73K validation words, and 82K test words) and has a vocabulary of size 10K. We train LSTMs of three sizes; these are denoted the small/medium/large LSTM. All LSTMs have two layers and are unrolled for 20 steps. The small, medium and large LSTM has 200, 650 and 1500 units per layer, respectively.
We study the effects of different types of architecture (LSTM/GRU/Vanilla RNN (Karpathy et al., 2016)) on the WP dataset, and effects of different learning algorithms on the PTB dataset. The comparison of test cross-entropy loss on WP is shown in Table 2. We observe that pSGLD consistently outperforms RMSprop. Table 3 summarizes the test set performance on PTB1. It is clear that our sampling-based method consistently outperforms the optimization counterpart, where the performance gain mainly comes from adding gradient noise and model averaging. When compared with dropout, SGLD performs better on the small LSTM model, but slightly worse on the medium and large LSTM model. This may imply that dropout is suitable to regularizing large networks, while SGLD exhibits better regularization ability on small networks, partially due to the fact that dropout may inject a higher level of noise during training than SGLD. In order to inject a higher level of noise into SGLD, we empirically apply SGLD and dropout jointly, and found that this provided the best performace on the medium and large LSTM model.
We study three strategies to do model averaging, i.e., forward collection, backward collection and thinned collection. Given samples (θ1, · · · ,θK) and the number of samples S used for averaging, forward collection refers to using (θ1, · · · ,θS) for
1The results reported here do not match (Zaremba et al., 2014) due to the differences of experimental setup. However, we provide a fair comparison to all methods.
Methods LSTM GRU RNN RMSprop 1.3607 1.2759 1.4239 pSGLD 1.3375 1.2561 1.4093
Table 3: Test perplexity on Penn Treebank.
Methods Small Medium Large SGD 123.85 126.31 130.25 SGD+Dropout 136.39 100.12 97.65 SGLD 117.36 109.14 105.86 SGLD+Dropout 139.54 99.58 94.03
10 20 30 40 50 60 Individual Sample
110 120 130 140 150 160 170 180 Pe rp le xi
ty 0 10 20 30 40 50 60 Number of Samples for Model Averaging
110 120 130 140 150 160 170 180 Pe rp le xi ty
forward collection backward collection thinned collection
(a) Single sample (b) Different collections
Figure 2: Effects of collected samples.
the evaluation of a test function, backward collection refers to using (θK−S+1, · · · ,θK), while thinned collection chooses samples from θ1 to θK with interval K/S. Fig. 2 plots the effects of these strategies, where Fig. 2(a) plots the perplexity of every single sample, Fig. 2(b) plots the perplexities using the three schemes. Only after 20 samples is a converged perplexity achieved in the thinned collection, while it requires 30 samples for forward collection or 60 samples for backward collection. This is unsurprising, because thinned collection provides a better way to select samples. Nevertheless, averaging of samples provides significantly lower perplexity than using single samples. Note that the overfitting problem in Fig. 2(a) is also alleviated by model averaging.
To better illustrate the benefit of model averaging, we visualize in Fig. 3 the probabilities of each word in a randomly chosen test sentence. The first 3 rows are the results predicted by 3 distinctive model samples, respectively; the bottom row is the result after averaging. Their corresponding perplexities for the test sentence are also shown on the right of each row. The 3 individual samples provide reasonable probabilities. For example, the consecutive words “New York”, “stock exchange” and “did not” are assigned with a higher probability. After averaging, we can see a much lower perplexity, as the samples can complement each other. For example, though the second sample can
7
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
Methods B-1 B-2 B-3 B-4 METEOR CIDEr ROUGE-L Perp. Results on Flickr8k RMSprop 0.640 0.427 0.288 0.197 0.205 0.476 0.500 16.64 RMSprop + Dropout 0.647 0.444 0.305 0.209 0.208 0.514 0.510 15.72 pSGLD 0.669 0.463 0.321 0.224 0.214 0.535 0.522 14.29 pSGLD + Dropout 0.656 0.450 0.309 0.211 0.209 0.512 0.512 14.26 Results on Flickr30k RMSprop 0.644 0.422 0.279 0.184 0.180 0.372 0.476 17.80 RMSprop + Dropout 0.656 0.435 0.295 0.200 0.185 0.396 0.481 18.05 pSGLD 0.657 0.438 0.300 0.206 0.192 0.421 0.490 15.61 pSGLD + Dropout 0.666 0.448 0.308 0.209 0.189 0.419 0.487 17.05
25.55the new york stock exchange did not fall apart 22.24the new york stock exchange did not fall apart 29.83the new york stock exchange did not fall apart
21.98the new york stock exchange did not fall apart 0
0.2
0.4
0.6
0.8
1
Figure 3: Predictive probabilities obtained by 3 samples and their average. Colors indicate normalized probability of each word. Best viewed in color.
a"tan"dog"is"playing"in"the"grass a"tan"dog"is"playing"with"a"red"ball"in"the"grass a"tan"dog"with"a"red"collar"is"running"in"the"grass
a"yellow"dog"runs"through"the"grass a"yellow"dog"is"running"through"the"grass a"brown"dog"is"running"through"the"grass
a"group"of"people"stand"in"front"of"a"building a"group"of"people"stand"in"front"of"a"white"building a"group"of"people"stand"in"front"of"a"large"building
a"man"and"a"woman"walking"on"a"sidewalk a"man"and"a"woman"stand"on"a"balcony a"man"and"a"woman"standing"on"the"ground
Figure 4: Image captioning with different samples. Left are the given images, right are the corresponding captions. The captions in each box are from the same model sample.
yield the lowest single-model perplexity, its prediction on word “York” is still benefited from the other two via averaging.
5.2 Image Caption Generation
We next consider the problem of image caption generation, which is a conditional RNN model, where image features are extracted by residual network (He et al., 2016), and then fed into the RNN to generate the caption. We present results on two benchmark datasets, Flickr8k (Hodosh et al., 2013) and Flickr30k (Young et al., 2014). These datasets contain 8,000 and 31,000 images, respectively. Each image is annotated with 5 sentences. A single-layer LSTM is employed with the number of hidden units set to 512.
The widely used BLEU (Papineni et al., 2002),
METEOR (Banerjee and Lavie, 2005), ROUGEL (Lin, 2004), and CIDEr-D (Vedantam et al., 2015) metrics are used to evaluate the performance. All the metrics are computed by using the code released by the COCO evaluation server (Chen et al., 2015b).
Table 4 presents results for pSGLD/RMSprop with or without dropout. Consistent with the results in the basic language modeling, pSGLD yields improved performance compared to RMSprop. For example, pSGLD provides 2.77 BLEU-4 score improvement over RMSprop on the Flickr8k dataset. By comparing pSGLD with RMSprop with dropout, we conclude that pSGLD exhibits better regularization ability than dropout on these two datasets.
Apart from modeling weight uncertainty, different samples from our algorithm may capture different aspects of the input image. An example with two images is shown in Fig. 4, where 2 randomly chosen model samples are considered for each image. For each model sample, the top 3 generated captions are presented. We use the beam search approach (Vinyals et al., 2015) to generate captions, with a beam of size 5. In Fig. 4, the two samples for the first image mainly differ in the color and activity of the dog, e.g., “tan” or “yellow”, “playing” or “running”, whereas for the second image, the two samples reflect different understanding of the image content.
5.3 Sentence Classification
We study the task of sentence classification on 5 datasets as in (Kiros et al., 2015): TREC (Li and Roth, 2002), MR (Pang and Lee, 2005), SUBJ (Pang and Lee, 2004), CR (Hu and Liu, 2004) and MPQA (Wiebe et al., 2005). A singlelayer bidirectional LSTM is employed with the
8
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
Table 5: Sentence classification errors on five benchmark datasets.
Methods MR CR SUBJ MPQA TREC RMSprop 21.26±1.45 22.70±2.20 8.13±1.19 10.60±1.28 8.58±0.79 RMSprop + Dropout 20.33±0.67 20.70±2.22 7.24±0.86 10.66±0.74 7.82±0.66 RMSprop + Gal’s Dropout 19.66±0.60 20.21±2.34 7.52±1.17 10.59±1.12 8.32±0.52 pSGLD 20.36±1.09 21.18±1.90 7.43±1.21 10.54±0.99 7.88±0.72 pSGLD + Dropout 19.48±0.95 19.74±2.03 6.61±1.06 10.22±0.89 7.32±0.66
5 10 15 #Epoch
0.00
0.05
0.10
0.15
0.20
0.25
Er ro
r
Train RMSprop RMSprop + Dropout pSGLD pSGLD + Dropout
5 10 15 #Epoch
0.10
0.12
0.14
0.16
0.18
0.20
0.22
0.24
0.26
Er ro
r
Validation
5 10 15 #Epoch
0.10
0.15
0.20
Er ro
r
Test
Figure 5: Learning curves on TREC dataset.
number of hidden units set to 400. Table 5 shows the testing classification errors. 10-fold cross-validation is used for evaluation on the first 4 datasets, while TREC has a pre-defined training/test split, and we run each algorithm 10 times on TREC. In addition to (naive) dropout, we further compare pSGLD with the Gal’s dropout, recently proposed in (Gal and Ghahramani, 2016b), which is shown to be applicable to recurrent layers. The combination of pSGLD and dropout consistently provides the lowest errors.
In the following, we focus on the analysis of TREC. Each sentence of TREC is a question, and the goal is to decide which topic type the question is most related to: location, human, numeric, abbreviation, entity or description. Fig. 5 plots the learning curves of different algorithms on the training, validation and testing sets of the TREC dataset. pSGLD and dropout have similar behavior: they explore the parameter space during learning, and thus coverge slower than RSMprop on the training dataset. However, the learned uncertainty alleviates overfitting and results in lower errors on the validation and testing datasets.
To further study the Bayesian nature of the proposed approach, in Fig. 6 we choose two testing sentences with high uncertainty (i.e., standard derivation in prediction) from the TREC dataset. Interestingly, after embedding to 2d-space with tSNE (Van der Maaten and Hinton, 2008), the two sentences correspond to points lying on the boundary of different classes. We use 20 model sam-
Whatdoes cc in engines mean?
Whatdoes adefibrillatordo?
True5Type Predicted5 Type
Description
Description
Testing5Question
Entity
Abbreviation
Figure 6: Visualization. Top two rows show selected ambiguous sentences, which correspond to the points with black circles in tSNE visualization of the testing dataset.
ples to estimate the prediction mean and standard derivation on the true type and predicted type. The classifier yields higher probability on the wrong types, associated with higher standard derivations. One can leverage the uncertainty information to make decisions: either manually make a human judgement when uncertainty is high, or automatically choose the one with lower standard derivations when both types exhibits similar prediction means. A more rigorous usage of the uncertainty information is left as future work.
6 Conclusion
We propose a scalable Bayesian learning framework using SG-MCMC, to model weight uncertainty in recurrent neural networks. The learning framework is tested on several tasks, including language models, image caption generation and sentence classification. Our algorithm outperforms stochastic optimization algorithms, indicating the importance of learning weight uncertainty in recurrent neural networks. Our algorithm requires little additional computational overhead in training, and multiple times of forward-passing for model averaging in testing. Future works include improving the testing efficiency for the large-scale RNNs, via learning a single neural network that approximates the model averaging result (Korattikara et al., 2015).
9
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899

Review:
- Strengths:  a) The paper presents a Bayesian learning approach for recurrent neural network language model. The method outperforms standard SGD with dropout on three tasks.  b) The idea of using Bayesian learning with RNNs appears to be novel.  c) The computationally efficient Bayesian algorithm for RNN would be of interest to the NLP community for various applications.  - Weaknesses:  Primary concern is about evaluation:  Sec 5.1: The paper reports the performance of difference types of architectures (LSTM GRU vanilla RNN) on character LM task while comparing the learning algorithms on the Penn Treebank task. Furthermore, RMSprop and pSGLD are compared for the character LM while SGD + - dropout is compared with SGLD + - dropout on word language model task. This is inconsistent!  I would suggest reporting both these dimensions (i.e. architectures and the exact same learning algorithms) on both character and word LM tasks. It would be useful to know if the results from the proposed Bayesian learning approaches are portable across both these tasks and data sets.  L529: The paper states that 'the performance gain mainly comes from adding gradient noise and model averaging'. This statement is not justified empirically. To arrive at this conclusion, an A B experiment with without adding gradient noise and or model averaging needs to be done.   L724: Gal's dropout is run on the sentence classification task but not on language model captions task. Since Gal's dropout is not specific to sentence classification,  I would suggest reporting the performance of this method on all three tasks. This would allow the readers to fully assess the utility of the proposed algorithms relative to all existing dropout approaches.  L544: Is there any sort order for the samples? (  theta_1, ...,   theta_K)? e.g. are samples with higher posterior probabilities likely to be at higher indices? Why not report the result of randomly selecting K out of S samples, as an additional alternative?  Regular RNN LMs are known to be expensive to train and evaluate. It would be very useful to compare the training evaluation times for the proposed Bayesian learning algorithms with SGD+ dropout. That would allow the readers to trade-off improvements versus increase in training run times.  Clarifications: L346: What does   theta_s refer to? Is this a MAP estimate of parameters based on only the sample s? L453-454: Clarify what   theta means in the context of dropout dropconnect.   Typos: L211: output L738: RMSProp