Learning Deep Structured Models

Summary:
Many problems in real-world applications involve predicting several random
variables which are statistically related. Markov random fields (MRFs) are a
great mathematical tool to encode such relationships. The goal of this paper is
to combine MRFs with deep learning algorithms to estimate complex
representations while taking into account the dependencies between the output
random variables. Towards this goal, we propose a training algorithm that is
able to learn structured models jointly with deep features that form the MRF
potentials. Our approach is efficient as it blends learning and inference and
makes use of GPU acceleration. We demonstrate the effectiveness of our
algorithm in the tasks of predicting words from noisy images, as well as
multi-class classification of Flickr photographs. We show that joint learning
of the deep features and the MRF parameters results in significant performance
gains.

Liang-Chieh Chen
Alexander G. Schwing
Alan L. Yuille
Raquel Urtasun

11 pages including reference

Accepted as a workshop contribution at ICLR 2015
LEARNING DEEPSTRUCTURED MODELS
Liang-Chieh Chen
Department of Computer Science, UCLA, lcchen@cs.ucla.edu
Alexander G. Schwing
Department of Computer Science, University of Toronto, aschwing@cs.toronto.edu
Alan L. Yuille
Department of Statistics, UCLA, yuille@stat.ucla.edu
Raquel Urtasun
Department of Computer Science, University of Toronto, urtasun@cs.toronto.edu
ABSTRACT
Many problems in real-world applications involve predicting several random vari-
ables which are statistically related. Markov random ﬁelds (MRFs) are a great
mathematical tool to encode such relationships. The goal of this paper is to com-
bine MRFs with deep learning algorithms to estimate complex representations
while taking into account the dependencies between the output random variables.
Towards this goal, we propose a training algorithm that is able to learn structured
models jointly with deep features that form the MRF potentials. Our approach is
efﬁcient as it blends learning and inference and makes use of GPU acceleration.
We demonstrate the effectiveness of our algorithm in the tasks of predicting words
from noisy images, as well as multi-class classiﬁcation of Flickr photographs. We
show that joint learning of the deep features and the MRF parameters results in
signiﬁcant performance gains.
1 I NTRODUCTION
Deep learning algorithms attempt to model high-level abstractions of the data using architec-
tures composed of multiple non-linear transformations. A multiplicity of variants have been pro-
posed (Hinton et al., 1984; LeCun et al., 1998; Hinton & Salakhutdinov, 2006; Bengio et al., 2007;
Salakhutdinov & Hinton, 2012; Zeiler & Fergus, 2014) and shown to be extremely successful in a
wide variety of applications including object detection, speech recognition as well as natural lan-
guage processing (Lee et al., 2009; Socher et al., 2012; Jia, 2013; Krizhevsky et al., 2013; Eigen
et al., 2014). Recently, state-of-the-art results have been achieved in many computer vision tasks,
outperforming competitive methods by a large margin (Krizhevsky et al., 2013; Girshick et al.,
2014).
Deep neural networks can, however, be even more powerful when combined with graphical models
in order to capture the statistical dependencies between the variables of interest. For example, Deng
et al. (2014) exploit mutual exclusion, overlapping and subsumption properties of class labels in or-
der to better predict in large scale classiﬁcation tasks. In pose estimation, more accurate predictions
can be obtained when encoding the spatial relationships between joint locations (Tompson et al.,
2014).
It is, however, an open problem how to develop scalable deep learning algorithms that can learn
higher-order knowledge taking into account the output variable’s dependencies. Existing approaches
often rely on a two-step process (Nowozin et al., 2011; Xu et al., 2014) where a non-linear classiﬁer
that employs deep features is trained ﬁrst, and its output is used to generate potentials for the struc-
tured predictor. This piece-wise training is, however, suboptimal as the deep features are learned
The ﬁrst two authors contributed equally to this work.
1arXiv:1407.2538v3  [cs.LG]  27 Apr 2015
Accepted as a workshop contribution at ICLR 2015
while ignoring the dependencies between the variables of interest, e.g., independently learned seg-
mentation and detection features (Hariharan et al., 2014) might be focusing on predicting the same
examples correctly. But when learned jointly they can improve their predictive power by exploiting
complementary information to ﬁx additional mistakes.
In this paper we extend deep learning algorithms to learn complex representations taking into ac-
count the dependencies between the output random variables. Towards this goal, we propose a
learning algorithm that is able to learn structured models with arbitrary graphs jointly with deep
features that form Markov random ﬁeld (MRF) potentials. Our approach is efﬁcient as it blends
learning and inference resulting in a single loop algorithm which makes use of GPU acceleration.
We demonstrate the effectiveness of our method in the tasks of predicting words from noisy images,
and multi-class classiﬁcation of Flickr photographs. We show that joint learning of deep features
and MRF parameters results in big performance gains.
2 L EARNING DEEPSTRUCTURED MODELS
In this section we investigate how to learn ‘deep features’ that take into account the dependen-
cies between the output variables. Let y2Y be the set of random variables y= (y1;:::;yN)
that we are interested in predicting. In this work we assume the space of valid conﬁgurations to
be a product space, i.e.,Y=QN
i=1Yi, and the domain of each individual variable yito be dis-
crete, i.e.,Yi=f1;:::;jYijg. Given input data x2X and parameters w2RAof the function
F(x;y;w) :XY RA!R, inference amounts to ﬁnding the highest scoring conﬁguration
y= arg max yF(x;y;w):Note that ifFis a deep network and there are no connections between
the output variables to be predicted, inference corresponds to a forward pass to evaluate the function,
followed by independently ﬁnding the largest response for each variable. This can be interpreted as
inference in a graphical model with only unary potentials. However, for arbitrary graphical models
it is NP-hard to ﬁnd the maximizing conﬁguration ysince the inference program generally requires
a search over a space of sizeQN
i=1jYij. Note also that log-linear models are a special case of this
program, with F(x;y;w) =w>(x;y)and(x;y)denoting a feature vector computed using the
input-output pair (x;y).
In this work, we consider the general setting where F(x;y;w)is an arbitrary scalar-valued func-
tion ofwand(x;y). In our experiments Fis a function composition of non-linear base mappings
like convolutions, rectiﬁcations, pooling etc. We let the probability of an arbitrary conﬁguration ^y
be given by the annealed soft-max p(x;y)(^yjw;) =1
Z(x;w)exp(F(x;^y;w))1=:HerebyZ(x;w)
refers to the partition function, normalizing the distribution p(x;y)to lie within the probability sim-
plexviaZ(x;w) =P
^y2Yexp(F(x;^y;w))1=. The annealing/temperature parameter 0is
used to adjust the uniformity of the distribution. We consider general graphical models where the
computation of Z(x;w)is #P-hard.
2.1 L EARNING VIA GRADIENT DESCENT
During learning, given a training set Dof input-output pairs (x;y)2D, we are interested in ﬁnding
the parameters wof the model. We do so by maximizing the data likelihood, i.e., minimizing the
negative log-likelihood lnQ
(x;y)2Dp(x;y)(yjw;)which yields
min
wX
(x;y)2D(lnZ(x;w)F(x;y;w)): (1)
Note that this is equivalent to maximizing the cross-entropy between a target distri-
butionp(x;y);tg(^y) =(^y=y)placing all its mass on the groundtruth label,
and the model distribution p(x;y)(^yjw;). Hence Eq. (1) is equivalently obtained by
maxwP
(x;y);^y2Yp(x;y);tg(^y) lnp(x;y)(^yjw;). It is easily possible to incorporate more general tar-
get distributions into Eq. (1). Note also that = 0recovers the structured hinge loss objective.
Minimizing Eq. (1) w.r.t. wrequires computation of the gradient@
@wP
(x;y)2Dlnp(x;y)(yjw;),
which is given by a transformed difference between the distributions of the model p(x;y)(^yjw;)and
2
Accepted as a workshop contribution at ICLR 2015
Repeat until stopping criteria
1. Forward pass to compute F(x;^y;w)
2. Compute p(x;y)(^yjw;)
3. Backward pass via chain rule to obtain gradient
4. Update parameters w
Figure 1: Gradient descent algorithm for learning deep structured models.
the targetp(x;y);tg(^y):
X
(x;y)2DX
^y2Y@
@wF(x;^y;w)
p(x;y)(^yjw;)p(x;y);tg(^y)
: (2)
A gradient descent algorithm for minimizing Eq. (1) will iterate between the following steps: (i) For
a givenwevaluate the function F, (ii) compute the model distribution p(x;y)(^yjw;), (iii) propagate
the difference between the model and target distribution using a backward pass (resembling the chain
rule for composite functions) and (iv) update the parameters w. This is summarized in Fig. 1.
2.2 A PPROXIMATE LEARNING
Note that for general graphical models the exact computation of p(x;y)(^yjw;)is not possible. As a
consequence it is intractable to compute the exact gradient of the cost-function given in Eq. (2) and
one has to resort to approximate solutions.
Inspired by approximations used for log-linear models, we make use of the following identity (Wain-
wright & Jordan, 2008; Koller & Friedman, 2009):
lnZ(x;w) = max
p(x;y)(^y)2E[F(x;^y;w)] +H(p(x;y)); (3)
where Edenotes an expectation over p(x;y)(^y)andHrefers to the entropy.
For most applications, F(x;y;w)decomposes into a sum of functions, each depending on a local
subset of variables yr,i.e.,F(x;y;w) =P
r2Rfr(x;yr;w):Herebyris a restriction of the variable
tupley= (y1;:::;yN)to the subset rf1;:::;Ng,i.e.,yr= (yi)i2r. All subsets rrequired to
compute the model function Fare summarized in the set R.
Plugging this decomposition into Eq. (3), we equivalently get the log-partition function
lnZ(x;w)viamaxp(x;y)(^y)2P
r;^yrp(x;y);r(^yr)fr(x;^yr;w) +H(p(x;y));where we use
marginalsp(x;y);r(^yr) =P
ynyrp(x;y)(y).
Despite the assumed locality of the scoring function, the learning task remains computationally
challenging since the entropy H(p(x;y))can only be computed exactly for a very small set of models,
e.g., models for which the joint distribution p(x;y)(y)is equivalently described by low tree-width
models. In addition, the marginalization constraints are exponential in size.
To deal with both issues a common solution in log-linear models is to approximate the true marginals
p(x;y);rwith local beliefs b(x;y);rthat are not required to fulﬁll marginalization constraints globally,
but only locally (Wainwright & Jordan, 2008). That means marginals b(x;y);rare not required to arise
from a common joint distribution p(x;y). In addition, we approximate the entropy via the fractional
entropy (Wiegerinck & Heskes, 2003), i.e.,H(p(x;y))P
rcrH(b(x;y);r). Counting numbers cr
are employed to weight the marginal entropies. Putting all this together, we obtain the following
approximation for lnZ(x;w):
max
b(x;y)2C(x;y)X
r;^yrb(x;y);r(^yr)fr(x;^yr;w) +X
rcrH(b(x;y);r): (4)
Hereby beliefs are constrained to the local polytope
C(x;y)=(8r b (x;y);r2
8r;^yr;p2P(r)P
^ypn^yrb(x;y);p(^yp) =b(x;y);r(^yr);
3
Accepted as a workshop contribution at ICLR 2015
Let~cr;p=cp=(cr+P
p02P(r)cp0). Repeat until stopping criteria
1. Forward pass to compute fr(x;^yr;w)8(x;y);r;yr
2. Get beliefs b(x;y);r/exp^fr(x;^yr;w;)
crby iterating over r:8(x;y);p2P(r);^yr
(x;y);p!r(^yr) =cplnX
^ypn^yrexpfp(x;^yp;w)P
p02P(p)(x;y);p!p0(^yp) +P
r02C(p)nr(x;y);r0!p(^yr0)
cp
(x;y);r!p(^yr)/~cr;p0
@fr(x;^yr;w) +X
c2C(r)(x;y);c!r(^yc) +X
p2P(r)(x;y);p!r(^yr)1
A(x;y);p!r(^yr)
3. Backward pass via chain-rule for gradient g=P
(x;y);r;^yrb(x;y);r(^yr)rwfr(x;^yr;w)rwF(w)
4. Update parameters wusing stepsize viaw wg
Figure 2: Efﬁcient learning algorithm that blends learning and inference.
withP(r)the set of parents of region r,i.e.,P(r)fp2R :rpg, which subsumes those
regions for which we want the marginalization constraint to hold. Conversely, we deﬁne the set of
children asC(r) =fc2R:r2P(c)g.
We can thus rewrite the learning problem by plugging the approximations derived in Eq. (4) into
Eq. (1). This gives rise to the new approximated learning program
min
wX
(x;y)2D0
@max
b(x;y)2C(x;y)8
<
:X
r;^yrb(x;y);r(^yr)fr(x;^yr;w) +X
rcrH(b(x;y);r)9
=
;F(x;y;w)1
A:(5)
To iteratively update the parameters for the non-smooth approximated cost function given in Eq. (5)
we require a sub-gradient w.r.t. w, which in turn requires to solve the maximization w.r.t. the beliefs
bexactly. This is a non-trivial task in itself as inference in general graphical models is NP-hard.
Iterative message passing algorithms (Pearl, 1988; Yedidia et al., 2005; Wainwright et al., 2005;
Weiss et al., 2007; Meltzer et al., 2009) are typically employed. Importantly, note that combining
the procedure outlined in Fig. 1 with iterative message passing to approximate p(x;y)(^yjw;)results
in a double-loop algorithm which would be slow for many graphical models of interest.
2.3 E FFICIENT APPROXIMATE LEARNING BY BLENDING LEARNING AND INFERENCE
In this section we propose a more efﬁcient algorithm that is based on the principle of blending
learning ( i.e., parameter updates) and inference. Thus we are interested in only performing a single
message passing iteration before updating the parameters w. Note that simply reducing the number
of iterations is generally not an option as the obtained beliefs b(x;y);rare by no means accurate.
However, assuming all counting numbers crto be positive, we can derive an algorithm that is able
to interleave minimization w.r.t. wand maximization of the beliefs b. Such a procedure is more
efﬁcient as we are able to update the parameters wmuch more frequently.
To interleave both programs we convert maximization of the beliefs into a minimization by employ-
ing the dual program as detailed in the following claim. This is possible since the maximization
problem is concave in b(x;y)if8r,cr0.
Claim 1 Assumecr08rand letF(w) =P
(x;y)2DF(x;y;w)denote the sum of empirical
function observations. Let (x;y);r!p(^yr)be the Lagrange multipliers for each marginalization
constraintP
^ypn^yrb(x;y);p(^yp) =b(x;y);r(^yr)within the polytope C(x;y). Then the approximated
general structured prediction task shown in Eq. (5)is equivalent to
min
w;X
(x;y);rcrlnX
^yrexp^fr(x;^yr;w;)
crF(w); (6)
4
Accepted as a workshop contribution at ICLR 2015
banal julep resty
drein yojan mothy
Figure 3: Samples from the Word50 dataset. High degree of rotation, scaling and translation.
where we employed the re-parameterization score ^fr(x;^yr;w;) =fr(x;^yr;w) +P
c2C(r)(x;y);c!r(^yc)P
p2P(r)(x;y);r!p(^yr).
Proof: To obtain the dual of the maximization w.r.t. b(x;y)we utilize its Lagrangian L(x;y)=P
r;^yrb(x;y);r(^yr)^fr(x;^yr;w;)+P
rcrH(b(x;y);r):Maximization of the Lagrangian w.r.t. the pri-
mal variables bis possible by employing the relationship stated in Eq. (3) locally 8r. We then obtain
the dual function being the ﬁrst term in Eq. (6). For strict convexity, i.e.,cr>0, we recon-
struct the beliefs to be proportional to the exponentiated, loss-augmented re-parameterization score
b(x;y);r/exp^fr(x;^yr;w;)
cr:Forcr= 0the beliefs correspond to a uniform distribution over the set
of maximizers of the loss-augmented re-parameterization score ^fr(x;^yr;w;).
It is important to note that by applying duality we managed to convert the min-max task in Eq. (5)
into a single minimization as shown in Eq. (6). Performing block coordinate descent updates to
minimize Eq. (6), we are therefore able to interleave both, updating the weights ( i.e., learning) and
the messages ( i.e., inference). This results in a more efﬁcient algorithm, as inference does not have
to be run until convergence. Even a single update of the messages sufﬁces. We note that this is
possible only if cr08r. Strictly speaking, we require concavity only within the set of feasible
beliefsC(x;y). However, for simplicity we neglect this extension in the following.
Fig. 2 summarizes our efﬁcient deep structured prediction algorithm which iterates between the
following steps. Given parameters wwe perform a standard forward pass to compute fr(x;^yr;w)
for all regions. We then iterate through all regions rand use block-coordinate descent to ﬁnd the
globally optimal value of Eq. (6) w.r.t. (x;y);r!p(^yr)8(x;y);^yr;p2P(r). This can be done in
closed form and therefore is computed very efﬁciently. We refer the reader to Schwing (2013) for
a derivation in the log-linear setting. We then compute the gradient using a standard backward pass
before we update the parameters by performing a step of size along the negative gradient.
2.4 I MPLEMENTATION DETAILS
We implemented the general algorithm presented in Fig. 2 in C++ as a library for Linux, Windows
and OS X platforms. It supports usage of the GPU for the forward and backward pass using both,
standard linear algebra packages and manually tuned GPU-kernels. In addition to standard gradi-
ent descent, we allow speciﬁcation of both mini-batches, moments and different regularizers like
2-norm and1-norm. Between iterations the step-size can be reduced based on either the nega-
tive log-likelihood or validation set performance. Contrasting available deep learning packages, our
functionFis speciﬁed using a general computation tree. Hence we support an arbitrarily nested
function structure composed of data, parameters and function prototypes (convolution, afﬁne func-
tion aka fully connected, dropout, local response normalization, pooling, rectiﬁed linear, sigmoid
and softmax units). The aforementioned library is accompanied by a program performing learning,
inference and gradient checks. To accommodate for large datasets it reads data from HDF5 storage
while a second thread simultaneously performs the computation. Google protocol buffers are em-
ployed to effectively specify the function Fwithout the need to modify any source code. We will
release this library upon publication. We believe that it will be useful for many researchers.
5
Accepted as a workshop contribution at ICLR 2015
Graph MLP Method H1= 128H1= 256H1= 512H1= 768H1= 1024
1st order Markov One LayerUnary only 8.60 / 61.32 10.80 / 64.41 12.50 / 65.69 12.95 / 66.66 13.40 / 67.02
JointTrain 16.80 / 65.28 25.20 / 70.75 31.80 / 74.90 33.05 / 76.42 34.30 / 77.02
PwTrain 12.70 / 64.35 18.00 / 68.27 22.80 / 71.29 23.25 / 72.62 26.30 / 73.96
PreTrainJoint 20.65 /67.42 25.70 /71.65 31.70 / 75.56 34.50 /77.14 35.85 /78.05
2nd order Markov One LayerJointTrain 25.50 / 67.13 34.60 / 73.19 45.55 / 79.60 51.55 /82.37 54.05 /83.57
PwTrain 10.05 / 58.90 14.10 / 63.44 18.10 / 67.31 20.40 / 70.14 22.20 / 71.25
PreTrainJoint 28.15 /69.07 36.85 /75.21 45.75 /80.09 50.10 / 82.30 52.25 / 83.39
H1= 512H2= 32H2= 64H2= 128H2= 256H2= 512
1st order Markov Two LayerUnary only 15.25 / 69.04 18.15 / 70.66 19.00 / 71.43 19.20 / 72.06 20.40 / 72.51
JointTrain 35.95 / 76.92 43.80 / 81.64 44.75 / 82.22 46.00 / 82.96 47.70 / 83.64
PwTrain 34.85 / 79.11 38.95 / 80.93 42.75 / 82.38 45.10 / 83.67 45.75 / 83.88
PreTrainJoint 42.25 /81.10 44.85 /82.96 46.85 /83.50 47.95 /84.21 47.05 / 84.08
2nd order Markov Two LayerJointTrain 54.65 / 83.98 61.80 / 87.30 66.15 / 89.09 64.85 / 88.93 68.00 / 89.96
PwTrain 39.95 / 81.14 48.25 / 84.45 52.65 / 86.24 57.10 / 87.61 62.90 / 89.49
PreTrainJoint 62.60 /88.03 65.80 /89.32 68.75 /90.47 68.60 /90.42 69.35 /90.75
Table 1: Word / Character accuracy. Performance improves as (1) joint-training is employed, (2) the
model is more structured, and (3) deeper unary classiﬁers are utilized. The number of hidden units
for the ﬁrst and second layer are denoted as H1andH2respectively.
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz
00.511.522.533.544.55
x 1043004005006007008009001000Neg. Log−Likelihood
Iteration
JointTrain
PwTrain
PreTrainJoint
Unary weights distance-1 edges distance-2 edges Neg. Log-Likelihood
Figure 4: (left) Subset of the learned unary weights. Pairwise weights (middle two panels), the
darker, the larger the weight. (right) Negative log-likelihood for different learning approaches.
3 E XPERIMENTAL EVALUATION
We demonstrate the performance of our model on two tasks: word recognition and image classiﬁ-
cation. We investigate four strategies to learn the model parameters. ‘ Unary only ’ denotes training
only unary classiﬁers while ignoring the structure of the graphical model, i.e., pairwise weights are
equal to 0. ‘JointTrain ’ initializes all weights at random and trains them jointly. ‘ PwTrain ’ uses
piecewise training by ﬁrst training the unary potentials and then keeping them ﬁxed when learn-
ing the pairwise potentials. ‘ PreTrainJoint ’ pre-trains the unaries but jointly optimizes pairwise
weights as well as unary weights in a second step.
3.1 W ORD RECOGNITION : W ORD50
Our ﬁrst task consists of word recognition from noisy images. Towards this goal, we created a
challenging dataset by randomly selecting 50 words, each consisting of ﬁve characters. We then
generated writing variations of each word as follows: we took the lower case characters from the
Chars74K dataset (de Campos et al., 2009), and inserted them in random background image patches
(similar to Larochelle et al. (2007)) by alpha matting, i.e., characters have transparency. To increase
the difﬁculty, we perturbed each character image of size 2828by scaling, rotation and translation.
As shown in Fig. 3 the task is very challenging, some characters are fairly difﬁcult to recognize even
for humans. We denote the resulting dataset ‘ Word50 .’ The training, validation and test sets have
10;000,2;000and2;000variations of words respectively.
We experimented with graphical models composed of unary and pairwise regions deﬁned over ﬁve
random variables, one per character. We encode unary potentials fr(x;yi;wu)using multi-layer per-
ceptrons (MLPs) with rectiﬁed linear units (ReLU). Unless otherwise stated, we deﬁne all pairwise
6
Accepted as a workshop contribution at ICLR 2015
H1=128 H1=256 H1=512 H1=768 H1=1024161820222426283032343638

Linear
PairH16
PairH32
PairH64
H2=32 H2=64 H2=128 H2=256 H2=512343638404244464850

Linear
PairH16
PairH32
PairH64
One-Layer MLP Chain Two-Layer MLP Chain
Figure 5: Learning non-linear pairwise functions: Word recognition as a function of the number
of hidden units for the unary potential. Colors represent different number of hidden units for the
pairwise potentials. The y-axis shows the word accuracy of using Linear function, or 16 (PairH16),
32 (PairH32), and 64 (PairH64) hidden units for the pairwise function.
female/indoor/portrait sky/plant life/tree water/animals/sea animals/dog/indoor indoor/ﬂower/plant life
female/indoor/portrait sky/plant life/tree water/animals/sky animals/dog ;
Figure 6: Flickr test set images and some assigned tags as well as our predictions (bottom row).
interactions via
fr(x;yi;yj;wp) =X
mnWmn(yi=m;yj=n); (7)
wherer=fi;jg,wp=fWg,Wmnis the element of matrix W, andrefers to the indicator
function.
For all experiments, we share all unary weights across the nodes of the graphical model as well as all
pairwise weights for all edges. Note that due to the use of ReLU units, the negative log-likelihood
is non-smooth, non-linear and non-convex w.r.t. w. Because of the non-smoothness of F, we utilize
momentum based sub-gradient descent methods to estimate the weights. In particular, we use a
mini-batch size of 100, a step size of 0:01and a momentum of 0:95. If the unary potential is pre-
trained, the initial step size is reduced to 0:001. All the unary classiﬁers are trained with 100;000
iterations over mini-batches. For all experiments, the validation set is only used to decrease the
step size, i.e., if the accuracy on the validation set decreases, we reduce the step size by 0:5. We
use= 1, setcr= 1 for all regions r, and perform 10 message passing iterations to compute the
marginal beliefs b(x;y);rat step 2 in Fig. 2 when dealing with loopy models.
We experiment with two graphical models, Markov models of ﬁrst ( i.e., there are links only between
yiandyi+1) and second order ( i.e., there are links between yiandyi+1,yi+2) as well as two types of
unary potentials with varying degree of structure. We report two metrics, the average character and
word accuracy, which correspond to Hamming loss and zero-one loss respectively. Table 1 depicts
the results for the different models, learning strategies and number of hidden units. We observe the
following trends.
Joint training helps: Joint training with pre-trained unary classiﬁers (PreTrainJoint) outperforms
all the other approaches in almost all cases. The piecewise training method (PwTrain), unable to
adapt the non-linearities while learning pairwise weights, often leads to performance worse than
joint training.
Structure helps: Adding structure to the model is key to capture complex dependencies. As shown
in Table 1, more structured models ( i.e., second order Markov model) consistently improves perfor-
mance.
7
Accepted as a workshop contribution at ICLR 2015
0.00 0.68 0.04 0.06 0.02 0.24 0.03 −0.00 −0.01 0.01 0.04 −0.00 −0.05 −0.01 0.07 −0.01 −0.00 −0.12 0.04 0.01 0.01 0.02 0.04 0.02
0.68 0.00 0.06 0.06 −0.00 0.36 0.03 −0.08 −0.05 −0.03 0.02 −0.06 −0.12 −0.05 0.74 −0.04 −0.03 −0.21 0.01 −0.03 −0.03 −0.03 0.05 −0.03
0.04 0.06 0.00 0.05 −0.06 0.07 −0.12 −0.07 −0.35 −0.03 −0.46 −0.02 −0.34 0.11 0.02 −0.15 −0.14 −0.01 −0.07 −0.21 0.03 −0.08 0.06 −0.03
0.06 0.06 0.05 0.00 0.10 0.11 0.07 0.09 0.03 0.10 0.01 0.10 0.02 0.09 0.06 0.08 0.07 0.07 0.08 0.06 0.09 0.09 0.08 0.10
0.02 −0.00 −0.06 0.10 0.00 0.04 0.08 0.05 0.16 0.17 −0.02 0.09 −0.02 0.06 0.03 0.14 0.36 0.06 0.05 0.01 0.08 0.14 0.06 0.10
0.24 0.36 0.07 0.11 0.04 0.00 0.01 0.03 −0.02 0.05 −0.02 0.04 −0.01 0.03 0.12 0.02 0.01 −0.07 0.05 0.05 0.03 0.04 0.07 0.05
0.03 0.03 −0.12 0.07 0.08 0.01 0.00 0.02 0.14 0.07 0.14 0.04 0.05 0.03 0.06 0.08 0.07 −0.03 0.36 0.10 0.04 0.05 0.04 0.07
−0.00 −0.08 −0.07 0.09 0.05 0.03 0.02 0.00 0.02 0.07 −0.03 0.07 0.34 0.04 −0.04 0.04 0.04 0.02 0.05 0.06 0.06 0.06 0.02 0.07
−0.01 −0.05 −0.35 0.03 0.16 −0.02 0.14 0.02 0.00 0.12 0.22 0.04 0.24 −0.02 −0.00 0.44 0.12 −0.04 0.10 0.30 0.01 0.23 0.05 0.11
0.01 −0.03 −0.03 0.10 0.17 0.05 0.07 0.07 0.12 0.00 −0.00 0.09 0.09 0.07 0.01 0.12 0.26 0.06 0.06 0.10 0.07 0.12 0.07 0.18
0.04 0.02 −0.46 0.01 −0.02 −0.02 0.14 −0.03 0.22 −0.00 0.00 0.01 0.04 −0.05 0.06 0.08 −0.04 −0.06 0.14 0.09 −0.00 0.06 0.03 0.02
−0.00 −0.06 −0.02 0.10 0.09 0.04 0.04 0.07 0.04 0.09 0.01 0.00 0.04 0.07 −0.01 0.06 0.09 0.26 0.06 0.05 0.07 0.09 0.05 0.09
−0.05 −0.12 −0.34 0.02 −0.02 −0.01 0.05 0.34 0.24 0.09 0.04 0.04 0.00 −0.03 −0.07 0.09 0.01 0.01 0.08 0.68 0.02 0.05 −0.07 0.10
−0.01 −0.05 0.11 0.09 0.06 0.03 0.03 0.04 −0.02 0.07 −0.05 0.07 −0.03 0.00 −0.01 0.03 0.03 0.03 0.05 0.01 0.06 0.06 0.04 0.07
0.07 0.74 0.02 0.06 0.03 0.12 0.06 −0.04 −0.00 0.01 0.06 −0.01 −0.07 −0.01 0.00 0.00 −0.01 −0.10 0.04 −0.02 0.01 0.00 0.06 0.01
−0.01 −0.04 −0.15 0.08 0.14 0.02 0.08 0.04 0.44 0.12 0.08 0.06 0.09 0.03 0.00 0.00 0.09 −0.00 0.07 0.11 0.05 0.22 −0.01 0.10
−0.00 −0.03 −0.14 0.07 0.36 0.01 0.07 0.04 0.12 0.26 −0.04 0.09 0.01 0.03 −0.01 0.09 0.00 0.05 0.02 0.03 0.05 0.10 0.03 0.27
−0.12 −0.21 −0.01 0.07 0.06 −0.07 −0.03 0.02 −0.04 0.06 −0.06 0.26 0.01 0.03 −0.10 −0.00 0.05 0.00 0.02 0.00 0.22 0.03 −0.01 0.05
0.04 0.01 −0.07 0.08 0.05 0.05 0.36 0.05 0.10 0.06 0.14 0.06 0.08 0.05 0.04 0.07 0.02 0.02 0.00 0.11 0.06 0.08 0.07 0.06
0.01 −0.03 −0.21 0.06 0.01 0.05 0.10 0.06 0.30 0.10 0.09 0.05 0.68 0.01 −0.02 0.11 0.03 0.00 0.11 0.00 0.04 0.09 −0.00 0.12
0.01 −0.03 0.03 0.09 0.08 0.03 0.04 0.06 0.01 0.07 −0.00 0.07 0.02 0.06 0.01 0.05 0.05 0.22 0.06 0.04 0.00 0.06 0.05 0.07
0.02 −0.03 −0.08 0.09 0.14 0.04 0.05 0.06 0.23 0.12 0.06 0.09 0.05 0.06 0.00 0.22 0.10 0.03 0.08 0.09 0.06 0.00 0.06 0.10
0.04 0.05 0.06 0.08 0.06 0.07 0.04 0.02 0.05 0.07 0.03 0.05 −0.07 0.04 0.06 −0.01 0.03 −0.01 0.07 −0.00 0.05 0.06 0.00 0.07
0.02 −0.03 −0.03 0.10 0.10 0.05 0.07 0.07 0.11 0.18 0.02 0.09 0.10 0.07 0.01 0.10 0.27 0.05 0.06 0.12 0.07 0.10 0.07 0.00female
people
indoor
baby
sea
portrait
transport
flower
sky
lake
structures
bird
plant life
food
male
clouds
water
animals
car
tree
dog
sunset
night
river
femalepeopleindoorbabyseaportraittransportflowerskylakestructuresbirdplant lifefoodmalecloudswateranimalscartreedogsunsetnightriver
0 5000 100000246810x 105
Time [s]Neg. Log−Likelihood

w/o blend
w blend
0 5000 100000200040006000800010000
Time [s]Training error

w/o blend
w blend
(a) (b)
Figure 7: (a) Correlation matrix ( i.e., pairwise potentials) learned on the Flickr dataset. (b) Blending
learning and inference speeds-up training signiﬁcantly.
Deep helps: We tested our models using one layer and two-layer perceptrons with both short-
range and long-range connections in the MRF. For the two-layer MLP, the number of hidden units
in the ﬁrst layer is ﬁxed to H1= 512 , and we varied the number of hidden units H2in the second
layer. As shown in Table 1 we observe that the deeper and the more structured the model, the better
the performance we achieve. As expected, performance also grows with the number of hidden units.
Efﬁciency: Using GPUs, it takes on average 0.064s per iteration for the 1st order Markov model
and 0.104s for the 2nd order Markov model. The time employed for training the one layer vs. the
multi-layer models is approximately the same. Note that our approach is very efﬁcient, as this is the
time per iteration to train 831,166 weights.
Learned parameters: As shown in the left column of Fig. 4, the learned unary weights resemble
character strokes. The middle two panels show the learned pairwise weights for distance-1 edges
(i.e., edges with only neighboring connections) and distance-2 edges ( i.e., edges connecting every
other variable). For example, it shows that ‘q’ is likely to be followed by ‘u,’ and ‘e’ is likely to
be distance-2 away from ‘q’ in this dataset. On the right-most panel, we also show the negative
log-likelihood as a function of the number of joint training iterations. PreTrainJoint can achieve the
lowest cost value, while PwTrain has the highest value.
Non-linear pairwise functions: To further demonstrate the generality of our approach, we replaced
the linear pairwise function in Eq. (7) by a one-layer MLP, while keeping the other settings identical.
For this experiment we utilize a 1st order Markov model. As shown in Fig. 5, our model attains best
performance when using a non-linear pairwise function. We found 16 to 64 hidden units for the
non-linear pairwise function to be sufﬁcient for modeling the bi-gram combinations in this dataset.
In this case the largest model has 974,846 weights and training takes on average 0.068s per iteration.
3.2 I MAGE CLASSIFICATION : FLICKR
We next evaluate the importance of blending learning and inference. Towards this goal, we make
use of the Flickr dataset, which consists of 10;000training and 10;000test images from Flickr. The
task is to predict which of 38 possible tags should be assigned to each image. Fig. 6 shows some
examples. The graphical model has 38 binary random variables, each denoting the presence/absence
of a particular tag. We deﬁne the non-linear unaries fr(x;yi;wu)using the 8-layer deep-net archi-
tecture from Krizhevsky et al. (2013) followed by a 76-dimensional top layer. Hence the function
is composed out of two subsequent stacks of convolution, rectiﬁed linear (ReLU), pooling and local
response normalization units. Those are followed by three convolution–ReLU function pairs. After-
wards pooling is applied before two fully-connected–ReLU–dropout combinations are employed to
yield the input into a fully connected layer which ﬁnally computes the unary potentials. We employ
pairwise potentials similar to Eq. (7) which now fully model the correlations between any pair of
8
Accepted as a workshop contribution at ICLR 2015
output variables. This amounts to a total of 57;182;408parameters arising from the convolutional
units, fully connected units and corresponding biases as well as the pairwise weights.
We use a momentum based sub-gradient method for training with a mini-batch size of 300, a step
size of 0:0001 , a momentum of 0:95and set= 1 andcr= 18r. We initialized the deep-net
parameters using a model pre-trained on ImageNet (Deng et al., 2009). Our error metric is the
classiﬁcation error ( i.e., Hamming loss).
Joint training helps: The mean error for unary only potentials (‘Unary only’), piecewise training
(‘PwTrain’) and joint pretraining (‘PreTrainJoint’) is 9.36%, 7.70% and 7.25% respectively. Similar
to the Word50 dataset we observe that joint training is beneﬁcial. We provide examples for perfect
(two left-most images), roughly accurate and failing predictions (right image) in Fig. 6.
Learned pairwise weights: In Fig. 7(a) we illustrate the learned correlations for a subset of the 38
classes. We observe that the class ‘people’ correlates highly with ‘female,’ ‘male,’ and ‘portrait.’
The ‘indoor’ tag does not co-occur with ‘sky,’ ‘structures,’ ‘plant life’ and ‘tree.’ ‘Sea’ appears
typically with ‘water,’ ‘clouds,’ ‘lake’ and ‘sky.’
Efﬁciency of Blending: To illustrate that blending is indeed beneﬁcial we compare the negative
log-likelihood and the training error as a function of run-time in Fig. 7(b). The standard approach
is limited to 20 iterations of message passing to avoid time-consuming, repeated computation of a
stopping criterion involving both the approximated log-partition function and its dual. As show in
Fig. 7(b) blending learning and inference speeds up parameter estimation signiﬁcantly. For larger
graphical models, we expect the differences to be even more signiﬁcant.
4 D ISCUSSION & C ONCLUSION
Joint training of neural networks and graphical models: Neural Networks have been incorpo-
rated as unary potentials in graphical models. One of the earliest works by Bridle (1990) jointly opti-
mizes a system consisting of multilayer perceptrons and hidden Markov models for speech recogni-
tion. For document processing systems, Bottou et al. (1997) propose Graph Transformer Networks
to jointly optimize sub-tasks, such as word segmentation and character recognition. Several works
(Collobert et al., 2011; Peng et al., 2009; Ma et al., 2012; Do & Artieres, 2010; Prabhavalkar &
Fosler-Lussier, 2010; Morris & Fosler-Lussier, 2008) have extended the linear unary potential in
MRFs to incorporate non-linearities. However, they assume that exact inference can be performed
either via a forward-backward pass within the graphical model or dynamic programming. In con-
trast, in this paper we present learning algorithms for general graphical models, where inference is
hard. Moreover, all the previous works (except Do & Artieres (2010)) do not consider max-margin
loss during training which is incorporated into our framework by choosing = 0. More recently, Li
& Zemel (2014) use a hinge loss to learn the unary term deﬁned as a neural net, but keep the pairwise
potentials ﬁxed ( i.e., no joint training). Domke (2013) considers non-linear structured prediction and
decomposes the learning problem into a subset of logistic regressors, which require the parameter
updates to be run till convergence before updating the messages. Tompson et al. (2014) also jointly
train convolutional neural networks and a graphical model for pose estimation. However, the MRF
inference procedure is approximated by their Spatial-Model which ignores the partition function.
Blending learning and inference: In this paper we deﬁned learning to be a min-max task. The
blending strategy, which was previously employed for learning log-linear models by (Meshi et al.,
2010; Hazan & Urtasun, 2010), amounts to converting the maximization task into a minimization
problem using its dual. Subsequently we make use of block-coordinate descent strategies to obtain
a more efﬁcient algorithm. Importantly any order of block-updates is possible. It remains an open
problem to ﬁnd the optimal tradeoff.
We have proposed an efﬁcient algorithm to learn deep models enriched to capture the dependencies
between the output variables. Our experiments on word prediction from noisy images and multi-
class image classiﬁcation showed that the deeper and the more structured the model, the better the
performance we achieve. Furthermore, joint learning of all weights outperforms all other strate-
gies. In the future we plan to learn deeper models in applications such as holistic semantic scene
understanding. We will also extend our approach to deal with hidden variables.
9
Accepted as a workshop contribution at ICLR 2015
ACKNOWLEDGMENTS
We thank NVIDIA Corporation for the donation of GPUs used in this research. This work was
partially funded by ONR-N00014-14-1-0232.
REFERENCES
Bengio, Y ., Lamblin, P., Popovici, D., and Larochelle, H. Greedy Layer-Wise Training of Deep Networks. In
Proc. NIPS , 2007.
Bottou, L., Bengio, Y ., and LeCun, Y . Global training of document processing systems using graph transformer
networks. In Proc. CVPR , 1997.
Bridle, J. S. Training stochastic model recognition algorithms as networks can lead to maximum mutual infor-
mation estimation of parameters. In Proc. NIPS , 1990.
Collobert, R., Weston, J., Bottou, L., Karlen, M., Kavukcuoglu, K., and Kuksa, P. Natural language processing
(almost) from scratch. JMLR , 2011.
de Campos, T. E., Babu, B. R., and Varma, M. Character recognition in natural images. In Proc. VISAPP , 2009.
Deng, J., Dong, W., Socher, R., Li, L.-J., Li, K., and Fei-Fei, L. Imagenet: A large-scale hierarchical image
database. In Proc. CVPR , 2009.
Deng, J., Ding, N., Jia, Y ., Frome, A., Murphy, K., Bengio, S., Li, Y ., Neven, H., and Adam, H. Large-Scale
Object Classiﬁcation using Label Relation Graphs. In Proc. ECCV , 2014.
Do, T.-M.-T. and Artieres, T. Neural conditional random ﬁelds. In Proc. AISTATS , 2010.
Domke, J. Structured Learning via Logistic Regression. In Proc. NIPS , 2013.
Eigen, D., Rolfe, J., Fergus, R., and LeCun, Y . Understanding Deep Architectures using a Recursive Convolu-
tional Network. In Proc. ICLR , 2014.
Girshick, R., Donahue, J., Darrell, T., and Malik, J. Rich feature hierarchies for accurate object detection and
semantic segmentation. In Proc. CVPR , 2014.
Hariharan, B., Arbel ´aez, P., Girshick, R., and Malik, J. Simultaneous detection and segmentation. In Proc.
ECCV , 2014.
Hazan, T. and Urtasun, R. A Primal-Dual Message-Passing Algorithm for Approximated Large Scale Struc-
tured Prediction. In Proc. NIPS , 2010.
Hinton, G. E. and Salakhutdinov, R. R. Reducing the dimensionality of data with neural networks. Science ,
2006.
Hinton, G. E., Sejnowski, T. J., and Ackley, D. H. Boltzmann Machines: Constraint Satisfaction Networks that
Learn. Technical report, University of Toronto, 1984.
Jia, Y . Caffe: An Open Source Convolutional Architecture for Fast Feature Embedding. http://caffe.
berkeleyvision.org/ , 2013.
Koller, D. and Friedman, N. Probabilistic Graphical Models: Principles and Techniques . MIT Press, 2009.
Krizhevsky, A., Sutskever, I., and Hinton, G. E. ImageNet Classiﬁcation with Deep Convolutional Neural
Networks. In Proc. NIPS , 2013.
Larochelle, H., Erhan, D., Courville, A., Bergstra, J., and Bengio, Y . An empirical evaluation of deep architec-
tures on problems with many factors of variation. In Proc. ICML , 2007.
LeCun, Y ., Bottou, L., Bengio, Y ., and Haffner, P. Gradient-based learning applied to document recognition.
Proceedings of the IEEE , 1998.
Lee, H., Grosse, R., Ranganath, R., and Ng, A. Y . Convolutional deep belief networks for scalable unsupervised
learning of hierarchical representations. In Proc. ICML , 2009.
Li, Y . and Zemel, R. High Order Regularization for Semi-Supervised Learning of Structured Output Problems.
InProc. ICML , 2014.
10
Accepted as a workshop contribution at ICLR 2015
Ma, J., Peng, J., Wang, S., and Xu, J. A conditional neural ﬁelds model for protein threading. Bioinformatics ,
2012.
Meltzer, T., Globerson, A., and Weiss, Y . Convergent Message Passing Algorithms: a unifying view. In Proc.
UAI, 2009.
Meshi, O., Sontag, D., Jaakkola, T., and Globerson, A. Learning Efﬁciently with Approximate inference via
Dual Losses. In Proc. ICML , 2010.
Morris, J. and Fosler-Lussier, E. Conditional random ﬁelds for integrating local discriminative classiﬁers. IEEE
Trans. Audio, Speech, and Language Processing , 2008.
Nowozin, S., Rother, C., Bagon, S., Sharp, T., Yao, B., and Kohli, P. Decision tree ﬁelds. In Proc. ICCV , 2011.
Pearl, J. Probabilistic Reasoning in Intelligent Systems: Networks of Plausible Inference . Morgan Kaufmann,
1988.
Peng, J., Bo, L., and Xu, J. Conditional Neural Fields. In Proc. NIPS , 2009.
Prabhavalkar, R. and Fosler-Lussier, E. Backpropagation training for multilayer conditional random ﬁeld based
phone recognition. In Proc. ICASSP , 2010.
Salakhutdinov, R. R. and Hinton, G. E. An Efﬁcient Learning Procedure for Deep Boltzmann Machines. Neural
Computation , 2012.
Schwing, A. G. Inference and Learning Algorithms with Applications to 3D Indoor Scene Understanding . PhD
thesis, ETH Zurich, 2013.
Socher, R., Huval, B., Bhat, B., Manning, C. D., and Ng, A. Y . Convolutional-Recursive Deep Learning for 3D
Object Classiﬁcation. In Proc. NIPS , 2012.
Tompson, J., Jain, A., LeCun, Y ., and Bregler, C. Joint Training of a Convolutional Network and a Graphical
Model for Human Pose Estimation. In Proc. NIPS , 2014.
Wainwright, M. J. and Jordan, M. I. Graphical Models, Exponential Families and Variational Inference . Foun-
dations and Trends in Machine Learning, 2008.
Wainwright, M. J., Jaakkola, T., and Willsky, A. S. A new class of upper bounds on the log partition function.
Trans. Information Theory , 2005.
Weiss, Y ., Yanover, C., and Meltzer, T. MAP Estimation, Linear Programming and Belief Propagation with
Convex Free Energies. In Proc. UAI , 2007.
Wiegerinck, W. and Heskes, T. Fractional belief propagation. In Proc. NIPS , 2003.
Xu, J., Schwing, A. G., and Urtasun, R. Tell me what you see and I will show you where it is. In Proc. CVPR ,
2014.
Yedidia, J. S., Freeman, W. T., and Weiss, Y . Constructing free-energy approximations and generalized belief
propagation algorithms. Trans. Information Theory , 2005.
Zeiler, M. D. and Fergus, R. Visualizing and Understanding Convolutional Networks. In Proc. ECCV , 2014.
11


Neural Machine Translation by Jointly Learning to Align and Translate

Summary:
Neural machine translation is a recently proposed approach to machine
translation. Unlike the traditional statistical machine translation, the neural
machine translation aims at building a single neural network that can be
jointly tuned to maximize the translation performance. The models proposed
recently for neural machine translation often belong to a family of
encoder-decoders and consists of an encoder that encodes a source sentence into
a fixed-length vector from which a decoder generates a translation. In this
paper, we conjecture that the use of a fixed-length vector is a bottleneck in
improving the performance of this basic encoder-decoder architecture, and
propose to extend this by allowing a model to automatically (soft-)search for
parts of a source sentence that are relevant to predicting a target word,
without having to form these parts as a hard segment explicitly. With this new
approach, we achieve a translation performance comparable to the existing
state-of-the-art phrase-based system on the task of English-to-French
translation. Furthermore, qualitative analysis reveals that the
(soft-)alignments found by the model agree well with our intuition.

Dzmitry Bahdanau
Kyunghyun Cho
Yoshua Bengio

Accepted at ICLR 2015 as oral presentation

Published as a conference paper at ICLR 2015
NEURAL MACHINE TRANSLATION
BYJOINTLY LEARNING TO ALIGN AND TRANSLATE
Dzmitry Bahdanau
Jacobs University Bremen, Germany
KyungHyun Cho Yoshua Bengio
Universit ´e de Montr ´eal
ABSTRACT
Neural machine translation is a recently proposed approach to machine transla-
tion. Unlike the traditional statistical machine translation, the neural machine
translation aims at building a single neural network that can be jointly tuned to
maximize the translation performance. The models proposed recently for neu-
ral machine translation often belong to a family of encoder–decoders and encode
a source sentence into a ﬁxed-length vector from which a decoder generates a
translation. In this paper, we conjecture that the use of a ﬁxed-length vector is a
bottleneck in improving the performance of this basic encoder–decoder architec-
ture, and propose to extend this by allowing a model to automatically (soft-)search
for parts of a source sentence that are relevant to predicting a target word, without
having to form these parts as a hard segment explicitly. With this new approach,
we achieve a translation performance comparable to the existing state-of-the-art
phrase-based system on the task of English-to-French translation. Furthermore,
qualitative analysis reveals that the (soft-)alignments found by the model agree
well with our intuition.
1 I NTRODUCTION
Neural machine translation is a newly emerging approach to machine translation, recently proposed
by Kalchbrenner and Blunsom (2013), Sutskever et al. (2014) and Cho et al. (2014b). Unlike the
traditional phrase-based translation system (see, e.g., Koehn et al. , 2003) which consists of many
small sub-components that are tuned separately, neural machine translation attempts to build and
train a single, large neural network that reads a sentence and outputs a correct translation.
Most of the proposed neural machine translation models belong to a family of encoder–
decoders (Sutskever et al. , 2014; Cho et al. , 2014a), with an encoder and a decoder for each lan-
guage, or involve a language-speciﬁc encoder applied to each sentence whose outputs are then com-
pared (Hermann and Blunsom, 2014). An encoder neural network reads and encodes a source sen-
tence into a ﬁxed-length vector. A decoder then outputs a translation from the encoded vector. The
whole encoder–decoder system, which consists of the encoder and the decoder for a language pair,
is jointly trained to maximize the probability of a correct translation given a source sentence.
A potential issue with this encoder–decoder approach is that a neural network needs to be able to
compress all the necessary information of a source sentence into a ﬁxed-length vector. This may
make it difﬁcult for the neural network to cope with long sentences, especially those that are longer
than the sentences in the training corpus. Cho et al. (2014b) showed that indeed the performance of
a basic encoder–decoder deteriorates rapidly as the length of an input sentence increases.
In order to address this issue, we introduce an extension to the encoder–decoder model which learns
to align and translate jointly. Each time the proposed model generates a word in a translation, it
(soft-)searches for a set of positions in a source sentence where the most relevant information is
concentrated. The model then predicts a target word based on the context vectors associated with
these source positions and all the previous generated target words.
CIFAR Senior Fellow
1arXiv:1409.0473v7  [cs.CL]  19 May 2016
Published as a conference paper at ICLR 2015
The most important distinguishing feature of this approach from the basic encoder–decoder is that
it does not attempt to encode a whole input sentence into a single ﬁxed-length vector. Instead, it en-
codes the input sentence into a sequence of vectors and chooses a subset of these vectors adaptively
while decoding the translation. This frees a neural translation model from having to squash all the
information of a source sentence, regardless of its length, into a ﬁxed-length vector. We show this
allows a model to cope better with long sentences.
In this paper, we show that the proposed approach of jointly learning to align and translate achieves
signiﬁcantly improved translation performance over the basic encoder–decoder approach. The im-
provement is more apparent with longer sentences, but can be observed with sentences of any
length. On the task of English-to-French translation, the proposed approach achieves, with a single
model, a translation performance comparable, or close, to the conventional phrase-based system.
Furthermore, qualitative analysis reveals that the proposed model ﬁnds a linguistically plausible
(soft-)alignment between a source sentence and the corresponding target sentence.
2 B ACKGROUND : NEURAL MACHINE TRANSLATION
From a probabilistic perspective, translation is equivalent to ﬁnding a target sentence ythat max-
imizes the conditional probability of ygiven a source sentence x, i.e., arg maxyp(yjx). In
neural machine translation, we ﬁt a parameterized model to maximize the conditional probability
of sentence pairs using a parallel training corpus. Once the conditional distribution is learned by a
translation model, given a source sentence a corresponding translation can be generated by searching
for the sentence that maximizes the conditional probability.
Recently, a number of papers have proposed the use of neural networks to directly learn this condi-
tional distribution (see, e.g., Kalchbrenner and Blunsom, 2013; Cho et al. , 2014a; Sutskever et al. ,
2014; Cho et al. , 2014b; Forcada and ˜Neco, 1997). This neural machine translation approach typ-
ically consists of two components, the ﬁrst of which encodes a source sentence xand the second
decodes to a target sentence y. For instance, two recurrent neural networks (RNN) were used by
(Cho et al. , 2014a) and (Sutskever et al. , 2014) to encode a variable-length source sentence into a
ﬁxed-length vector and to decode the vector into a variable-length target sentence.
Despite being a quite new approach, neural machine translation has already shown promising results.
Sutskever et al. (2014) reported that the neural machine translation based on RNNs with long short-
term memory (LSTM) units achieves close to the state-of-the-art performance of the conventional
phrase-based machine translation system on an English-to-French translation task.1Adding neural
components to existing translation systems, for instance, to score the phrase pairs in the phrase
table (Cho et al. , 2014a) or to re-rank candidate translations (Sutskever et al. , 2014), has allowed to
surpass the previous state-of-the-art performance level.
2.1 RNN E NCODER –DECODER
Here, we describe brieﬂy the underlying framework, called RNN Encoder–Decoder , proposed by
Cho et al. (2014a) and Sutskever et al. (2014) upon which we build a novel architecture that learns
to align and translate simultaneously.
In the Encoder–Decoder framework, an encoder reads the input sentence, a sequence of vectors
x= (x1;;xTx), into a vector c.2The most common approach is to use an RNN such that
ht=f(xt;ht1) (1)
and
c=q(fh1;;hTxg);
whereht2Rnis a hidden state at time t, andcis a vector generated from the sequence of the
hidden states. fandqare some nonlinear functions. Sutskever et al. (2014) used an LSTM as fand
q(fh1;;hTg) =hT, for instance.
1We mean by the state-of-the-art performance, the performance of the conventional phrase-based system
without using any neural network-based component.
2Although most of the previous works (see, e.g., Cho et al. , 2014a; Sutskever et al. , 2014; Kalchbrenner and
Blunsom, 2013) used to encode a variable-length input sentence into a ﬁxed-length vector, it is not necessary,
and even it may be beneﬁcial to have a variable-length vector, as we will show later.
2
Published as a conference paper at ICLR 2015
The decoder is often trained to predict the next word yt0given the context vector cand all the
previously predicted words fy1;;yt01g. In other words, the decoder deﬁnes a probability over
the translation yby decomposing the joint probability into the ordered conditionals:
p(y) =TY
t=1p(ytjfy1;;yt1g;c); (2)
where y=
y1;;yTy
. With an RNN, each conditional probability is modeled as
p(ytjfy1;;yt1g;c) =g(yt1;st;c); (3)
wheregis a nonlinear, potentially multi-layered, function that outputs the probability of yt, andstis
the hidden state of the RNN. It should be noted that other architectures such as a hybrid of an RNN
and a de-convolutional neural network can be used (Kalchbrenner and Blunsom, 2013).
3 L EARNING TO ALIGN AND TRANSLATE
In this section, we propose a novel architecture for neural machine translation. The new architecture
consists of a bidirectional RNN as an encoder (Sec. 3.2) and a decoder that emulates searching
through a source sentence during decoding a translation (Sec. 3.1).
3.1 D ECODER : GENERAL DESCRIPTION
x1x2x3xT+
αt,1
αt,2 αt,3αt,Tyt-1yt
h1h2h3 hTh1h2h3 hTst-1st
Figure 1: The graphical illus-
tration of the proposed model
trying to generate the t-th tar-
get wordytgiven a source
sentence (x1;x2;:::;x T).In a new model architecture, we deﬁne each conditional probability
in Eq. (2) as:
p(yijy1;:::;y i1;x) =g(yi1;si;ci); (4)
wheresiis an RNN hidden state for time i, computed by
si=f(si1;yi1;ci):
It should be noted that unlike the existing encoder–decoder ap-
proach (see Eq. (2)), here the probability is conditioned on a distinct
context vector cifor each target word yi.
The context vector cidepends on a sequence of annotations
(h1;;hTx)to which an encoder maps the input sentence. Each
annotationhicontains information about the whole input sequence
with a strong focus on the parts surrounding the i-th word of the
input sequence. We explain in detail how the annotations are com-
puted in the next section.
The context vector ciis, then, computed as a weighted sum of these
annotationshi:
ci=TxX
j=1ijhj: (5)
The weightijof each annotation hjis computed by
ij=exp (eij)PTx
k=1exp (eik); (6)
where
eij=a(si1;hj)
is an alignment model which scores how well the inputs around position jand the output at position
imatch. The score is based on the RNN hidden state si1(just before emitting yi, Eq. (4)) and the
j-th annotation hjof the input sentence.
We parametrize the alignment model aas a feedforward neural network which is jointly trained with
all the other components of the proposed system. Note that unlike in traditional machine translation,
3
Published as a conference paper at ICLR 2015
the alignment is not considered to be a latent variable. Instead, the alignment model directly com-
putes a soft alignment, which allows the gradient of the cost function to be backpropagated through.
This gradient can be used to train the alignment model as well as the whole translation model jointly.
We can understand the approach of taking a weighted sum of all the annotations as computing an
expected annotation , where the expectation is over possible alignments. Let ijbe a probability that
the target word yiis aligned to, or translated from, a source word xj. Then, thei-th context vector
ciis the expected annotation over all the annotations with probabilities ij.
The probability ij, or its associated energy eij, reﬂects the importance of the annotation hjwith
respect to the previous hidden state si1in deciding the next state siand generating yi. Intuitively,
this implements a mechanism of attention in the decoder. The decoder decides parts of the source
sentence to pay attention to. By letting the decoder have an attention mechanism, we relieve the
encoder from the burden of having to encode all information in the source sentence into a ﬁxed-
length vector. With this new approach the information can be spread throughout the sequence of
annotations, which can be selectively retrieved by the decoder accordingly.
3.2 E NCODER : BIDIRECTIONAL RNN FOR ANNOTATING SEQUENCES
The usual RNN, described in Eq. (1), reads an input sequence xin order starting from the ﬁrst
symbolx1to the last one xTx. However, in the proposed scheme, we would like the annotation
of each word to summarize not only the preceding words, but also the following words. Hence,
we propose to use a bidirectional RNN (BiRNN, Schuster and Paliwal, 1997), which has been
successfully used recently in speech recognition (see, e.g., Graves et al. , 2013).
A BiRNN consists of forward and backward RNN’s. The forward RNN !freads the input sequence
as it is ordered (from x1toxTx) and calculates a sequence of forward hidden states ( !h1;; !hTx).
The backward RNN freads the sequence in the reverse order (from xTxtox1), resulting in a
sequence of backward hidden states ( h1;; hTx).
We obtain an annotation for each word xjby concatenating the forward hidden state !hjand the
backward one hj, i.e.,hj=h !h>
j; h>
ji>
. In this way, the annotation hjcontains the summaries
of both the preceding words and the following words. Due to the tendency of RNNs to better
represent recent inputs, the annotation hjwill be focused on the words around xj. This sequence
of annotations is used by the decoder and the alignment model later to compute the context vector
(Eqs. (5)–(6)).
See Fig. 1 for the graphical illustration of the proposed model.
4 E XPERIMENT SETTINGS
We evaluate the proposed approach on the task of English-to-French translation. We use the bilin-
gual, parallel corpora provided by ACL WMT ’14.3As a comparison, we also report the perfor-
mance of an RNN Encoder–Decoder which was proposed recently by Cho et al. (2014a). We use
the same training procedures and the same dataset for both models.4
4.1 D ATASET
WMT ’14 contains the following English-French parallel corpora: Europarl (61M words), news
commentary (5.5M), UN (421M) and two crawled corpora of 90M and 272.5M words respectively,
totaling 850M words. Following the procedure described in Cho et al. (2014a), we reduce the size of
the combined corpus to have 348M words using the data selection method by Axelrod et al. (2011).5
We do not use any monolingual data other than the mentioned parallel corpora, although it may be
possible to use a much larger monolingual corpus to pretrain an encoder. We concatenate news-test-
3http://www.statmt.org/wmt14/translation-task.html
4Implementations are available at https://github.com/lisa-groundhog/GroundHog .
5Available online at http://www-lium.univ-lemans.fr/ ˜schwenk/cslm_joint_paper/ .
4
Published as a conference paper at ICLR 2015
0 10 20 30 40 50 60
Sentence length051015202530BLEU score RNNsearch-50
RNNsearch-30
RNNenc-50
RNNenc-30
Figure 2: The BLEU scores
of the generated translations
on the test set with respect
to the lengths of the sen-
tences. The results are on
the full test set which in-
cludes sentences having un-
known words to the models.
2012 and news-test-2013 to make a development (validation) set, and evaluate the models on the test
set (news-test-2014) from WMT ’14, which consists of 3003 sentences not present in the training
data.
After a usual tokenization6, we use a shortlist of 30,000 most frequent words in each language to
train our models. Any word not included in the shortlist is mapped to a special token ( [UNK ]). We
do not apply any other special preprocessing, such as lowercasing or stemming, to the data.
4.2 M ODELS
We train two types of models. The ﬁrst one is an RNN Encoder–Decoder (RNNencdec, Cho et al. ,
2014a), and the other is the proposed model, to which we refer as RNNsearch. We train each model
twice: ﬁrst with the sentences of length up to 30 words (RNNencdec-30, RNNsearch-30) and then
with the sentences of length up to 50 word (RNNencdec-50, RNNsearch-50).
The encoder and decoder of the RNNencdec have 1000 hidden units each.7The encoder of the
RNNsearch consists of forward and backward recurrent neural networks (RNN) each having 1000
hidden units. Its decoder has 1000 hidden units. In both cases, we use a multilayer network with a
single maxout (Goodfellow et al. , 2013) hidden layer to compute the conditional probability of each
target word (Pascanu et al. , 2014).
We use a minibatch stochastic gradient descent (SGD) algorithm together with Adadelta (Zeiler,
2012) to train each model. Each SGD update direction is computed using a minibatch of 80 sen-
tences. We trained each model for approximately 5 days.
Once a model is trained, we use a beam search to ﬁnd a translation that approximately maximizes the
conditional probability (see, e.g., Graves, 2012; Boulanger-Lewandowski et al. , 2013). Sutskever
et al. (2014) used this approach to generate translations from their neural machine translation model.
For more details on the architectures of the models and training procedure used in the experiments,
see Appendices A and B.
5 R ESULTS
5.1 Q UANTITATIVE RESULTS
In Table 1, we list the translation performances measured in BLEU score. It is clear from the table
that in all the cases, the proposed RNNsearch outperforms the conventional RNNencdec. More
importantly, the performance of the RNNsearch is as high as that of the conventional phrase-based
translation system (Moses), when only the sentences consisting of known words are considered.
This is a signiﬁcant achievement, considering that Moses uses a separate monolingual corpus (418M
words) in addition to the parallel corpora we used to train the RNNsearch and RNNencdec.
6We used the tokenization script from the open-source machine translation package, Moses.
7In this paper, by a ’hidden unit’, we always mean the gated hidden unit (see Appendix A.1.1).
5
Published as a conference paper at ICLR 2015
The
agreement
on
the
European
Economic
Area
was
signed
in
August
1992
.
<end>
L'
accord
sur
la
zone
économique
européenne
a
été
signé
en
août
1992
.
<end>
It
should
be
noted
that
the
marine
environment
is
the
least
known
of
environments
.
<end>
Il
convient
de
noter
que
l'
environnement
marin
est
le
moins
connu
de
l'
environnement
.
<end>
(a) (b)
Destruction
of
the
equipment
means
that
Syria
can
no
longer
produce
new
chemical
weapons
.
<end>
La
destruction
de
l'
équipement
signifie
que
la
Syrie
ne
peut
plus
produire
de
nouvelles
armes
chimiques
.
<end>
"
This
will
change
my
future
with
my
family
,
"
the
man
said
.
<end>
"
Cela
va
changer
mon
avenir
avec
ma
famille
"
,
a
dit
l'
homme
.
<end>
(c) (d)
Figure 3: Four sample alignments found by RNNsearch-50. The x-axis and y-axis of each plot
correspond to the words in the source sentence (English) and the generated translation (French),
respectively. Each pixel shows the weight ijof the annotation of the j-th source word for the i-th
target word (see Eq. (6)), in grayscale ( 0: black, 1: white). (a) an arbitrary sentence. (b–d) three
randomly selected samples among the sentences without any unknown words and of length between
10 and 20 words from the test set.
One of the motivations behind the proposed approach was the use of a ﬁxed-length context vector
in the basic encoder–decoder approach. We conjectured that this limitation may make the basic
encoder–decoder approach to underperform with long sentences. In Fig. 2, we see that the perfor-
mance of RNNencdec dramatically drops as the length of the sentences increases. On the other hand,
both RNNsearch-30 and RNNsearch-50 are more robust to the length of the sentences. RNNsearch-
50, especially, shows no performance deterioration even with sentences of length 50 or more. This
superiority of the proposed model over the basic encoder–decoder is further conﬁrmed by the fact
that the RNNsearch-30 even outperforms RNNencdec-50 (see Table 1).
6
Published as a conference paper at ICLR 2015
Model All No UNK
RNNencdec-30 13.93 24.19
RNNsearch-30 21.50 31.44
RNNencdec-50 17.82 26.71
RNNsearch-50 26.75 34.16
RNNsearch-50?28.45 36.15
Moses 33.30 35.63Table 1: BLEU scores of the trained models com-
puted on the test set. The second and third columns
show respectively the scores on all the sentences and,
on the sentences without any unknown word in them-
selves and in the reference translations. Note that
RNNsearch-50?was trained much longer until the
performance on the development set stopped improv-
ing. () We disallowed the models to generate [UNK]
tokens when only the sentences having no unknown
words were evaluated (last column).
5.2 Q UALITATIVE ANALYSIS
5.2.1 A LIGNMENT
The proposed approach provides an intuitive way to inspect the (soft-)alignment between the words
in a generated translation and those in a source sentence. This is done by visualizing the annotation
weightsijfrom Eq. (6), as in Fig. 3. Each row of a matrix in each plot indicates the weights
associated with the annotations. From this we see which positions in the source sentence were
considered more important when generating the target word.
We can see from the alignments in Fig. 3 that the alignment of words between English and French
is largely monotonic. We see strong weights along the diagonal of each matrix. However, we also
observe a number of non-trivial, non-monotonic alignments. Adjectives and nouns are typically
ordered differently between French and English, and we see an example in Fig. 3 (a). From this
ﬁgure, we see that the model correctly translates a phrase [European Economic Area] into [zone
´economique europ ´een]. The RNNsearch was able to correctly align [zone] with [Area], jumping
over the two words ([European] and [Economic]), and then looked one word back at a time to
complete the whole phrase [zone ´economique europ ´eenne].
The strength of the soft-alignment, opposed to a hard-alignment, is evident, for instance, from
Fig. 3 (d). Consider the source phrase [the man] which was translated into [l’ homme]. Any hard
alignment will map [the] to [l’] and [man] to [homme]. This is not helpful for translation, as one
must consider the word following [the] to determine whether it should be translated into [le], [la],
[les] or [l’]. Our soft-alignment solves this issue naturally by letting the model look at both [the] and
[man], and in this example, we see that the model was able to correctly translate [the] into [l’]. We
observe similar behaviors in all the presented cases in Fig. 3. An additional beneﬁt of the soft align-
ment is that it naturally deals with source and target phrases of different lengths, without requiring a
counter-intuitive way of mapping some words to or from nowhere ([NULL]) (see, e.g., Chapters 4
and 5 of Koehn, 2010).
5.2.2 L ONG SENTENCES
As clearly visible from Fig. 2 the proposed model (RNNsearch) is much better than the conventional
model (RNNencdec) at translating long sentences. This is likely due to the fact that the RNNsearch
does not require encoding a long sentence into a ﬁxed-length vector perfectly, but only accurately
encoding the parts of the input sentence that surround a particular word.
As an example, consider this source sentence from the test set:
An admitting privilege is the right of a doctor to admit a patient to a hospital or
a medical centre tocarry outadiagnosis oraprocedure, based onhisstatus asa
health care worker atahospital.
The RNNencdec-50 translated this sentence into:
Un privil `ege d’admission est le droit d’un m ´edecin de reconna ˆıtre un patient `a
l’hˆopital ou un centre m ´edical d’un diagnostic oudeprendre undiagnostic en
fonction deson´etatdesant´e.
7
Published as a conference paper at ICLR 2015
The RNNencdec-50 correctly translated the source sentence until [a medical center]. However, from
there on (underlined), it deviated from the original meaning of the source sentence. For instance, it
replaced [based on his status as a health care worker at a hospital] in the source sentence with [en
fonction de son ´etat de sant ´e] (“based on his state of health”).
On the other hand, the RNNsearch-50 generated the following correct translation, preserving the
whole meaning of the input sentence without omitting any details:
Un privil `ege d’admission est le droit d’un m ´edecin d’admettre un patient `a un
hˆopital ou un centre m ´edical pour effectuer undiagnostic ouuneproc´edure, selon
sonstatut detravailleur dessoins desant´e`al’hˆopital.
Let us consider another sentence from the test set:
This kind of experience is part of Disney’s efforts to ”extend the lifetime of its
series and build new relationships with audiences viadigital platforms that are
becoming ever more important, ” headded.
The translation by the RNNencdec-50 is
Ce type d’exp ´erience fait partie des initiatives du Disney pour ”prolonger la dur ´ee
de vie de ses nouvelles et de d ´evelopper des liens avec les lecteurs num´eriques qui
deviennent plus complexes.
As with the previous example, the RNNencdec began deviating from the actual meaning of the
source sentence after generating approximately 30 words (see the underlined phrase). After that
point, the quality of the translation deteriorates, with basic mistakes such as the lack of a closing
quotation mark.
Again, the RNNsearch-50 was able to translate this long sentence correctly:
Ce genre d’exp ´erience fait partie des efforts de Disney pour ”prolonger la dur ´ee
de vie de ses s ´eries et cr ´eer de nouvelles relations avec des publics viades
plateformes num´eriques deplus enplus importantes”, a-t-il ajout ´e.
In conjunction with the quantitative results presented already, these qualitative observations con-
ﬁrm our hypotheses that the RNNsearch architecture enables far more reliable translation of long
sentences than the standard RNNencdec model.
In Appendix C, we provide a few more sample translations of long source sentences generated by
the RNNencdec-50, RNNsearch-50 and Google Translate along with the reference translations.
6 R ELATED WORK
6.1 L EARNING TO ALIGN
A similar approach of aligning an output symbol with an input symbol was proposed recently by
Graves (2013) in the context of handwriting synthesis. Handwriting synthesis is a task where the
model is asked to generate handwriting of a given sequence of characters. In his work, he used a
mixture of Gaussian kernels to compute the weights of the annotations, where the location, width
and mixture coefﬁcient of each kernel was predicted from an alignment model. More speciﬁcally,
his alignment was restricted to predict the location such that the location increases monotonically.
The main difference from our approach is that, in (Graves, 2013), the modes of the weights of the
annotations only move in one direction. In the context of machine translation, this is a severe limi-
tation, as (long-distance) reordering is often needed to generate a grammatically correct translation
(for instance, English-to-German).
Our approach, on the other hand, requires computing the annotation weight of every word in the
source sentence for each word in the translation. This drawback is not severe with the task of
translation in which most of input and output sentences are only 15–40 words. However, this may
limit the applicability of the proposed scheme to other tasks.
8
Published as a conference paper at ICLR 2015
6.2 N EURAL NETWORKS FOR MACHINE TRANSLATION
Since Bengio et al. (2003) introduced a neural probabilistic language model which uses a neural net-
work to model the conditional probability of a word given a ﬁxed number of the preceding words,
neural networks have widely been used in machine translation. However, the role of neural net-
works has been largely limited to simply providing a single feature to an existing statistical machine
translation system or to re-rank a list of candidate translations provided by an existing system.
For instance, Schwenk (2012) proposed using a feedforward neural network to compute the score of
a pair of source and target phrases and to use the score as an additional feature in the phrase-based
statistical machine translation system. More recently, Kalchbrenner and Blunsom (2013) and Devlin
et al. (2014) reported the successful use of the neural networks as a sub-component of the existing
translation system. Traditionally, a neural network trained as a target-side language model has been
used to rescore or rerank a list of candidate translations (see, e.g., Schwenk et al. , 2006).
Although the above approaches were shown to improve the translation performance over the state-
of-the-art machine translation systems, we are more interested in a more ambitious objective of
designing a completely new translation system based on neural networks. The neural machine trans-
lation approach we consider in this paper is therefore a radical departure from these earlier works.
Rather than using a neural network as a part of the existing system, our model works on its own and
generates a translation from a source sentence directly.
7 C ONCLUSION
The conventional approach to neural machine translation, called an encoder–decoder approach, en-
codes a whole input sentence into a ﬁxed-length vector from which a translation will be decoded.
We conjectured that the use of a ﬁxed-length context vector is problematic for translating long sen-
tences, based on a recent empirical study reported by Cho et al. (2014b) and Pouget-Abadie et al.
(2014).
In this paper, we proposed a novel architecture that addresses this issue. We extended the basic
encoder–decoder by letting a model (soft-)search for a set of input words, or their annotations com-
puted by an encoder, when generating each target word. This frees the model from having to encode
a whole source sentence into a ﬁxed-length vector, and also lets the model focus only on information
relevant to the generation of the next target word. This has a major positive impact on the ability
of the neural machine translation system to yield good results on longer sentences. Unlike with
the traditional machine translation systems, all of the pieces of the translation system, including
the alignment mechanism, are jointly trained towards a better log-probability of producing correct
translations.
We tested the proposed model, called RNNsearch, on the task of English-to-French translation. The
experiment revealed that the proposed RNNsearch outperforms the conventional encoder–decoder
model (RNNencdec) signiﬁcantly, regardless of the sentence length and that it is much more ro-
bust to the length of a source sentence. From the qualitative analysis where we investigated the
(soft-)alignment generated by the RNNsearch, we were able to conclude that the model can cor-
rectly align each target word with the relevant words, or their annotations, in the source sentence as
it generated a correct translation.
Perhaps more importantly, the proposed approach achieved a translation performance comparable to
the existing phrase-based statistical machine translation. It is a striking result, considering that the
proposed architecture, or the whole family of neural machine translation, has only been proposed
as recently as this year. We believe the architecture proposed here is a promising step toward better
machine translation and a better understanding of natural languages in general.
One of challenges left for the future is to better handle unknown, or rare words. This will be required
for the model to be more widely used and to match the performance of current state-of-the-art
machine translation systems in all contexts.
9
Published as a conference paper at ICLR 2015
ACKNOWLEDGMENTS
The authors would like to thank the developers of Theano (Bergstra et al. , 2010; Bastien et al. ,
2012). We acknowledge the support of the following agencies for research funding and computing
support: NSERC, Calcul Qu ´ebec, Compute Canada, the Canada Research Chairs and CIFAR. Bah-
danau thanks the support from Planet Intelligent Systems GmbH. We also thank Felix Hill, Bart van
Merri ´enboer, Jean Pouget-Abadie, Coline Devin and Tae-Ho Kim.
REFERENCES
Axelrod, A., He, X., and Gao, J. (2011). Domain adaptation via pseudo in-domain data selection.
InProceedings of the ACL Conference on Empirical Methods in Natural Language Processing
(EMNLP) , pages 355–362. Association for Computational Linguistics.
Bastien, F., Lamblin, P., Pascanu, R., Bergstra, J., Goodfellow, I. J., Bergeron, A., Bouchard, N.,
and Bengio, Y . (2012). Theano: new features and speed improvements. Deep Learning and
Unsupervised Feature Learning NIPS 2012 Workshop.
Bengio, Y ., Simard, P., and Frasconi, P. (1994). Learning long-term dependencies with gradient
descent is difﬁcult. IEEE Transactions on Neural Networks ,5(2), 157–166.
Bengio, Y ., Ducharme, R., Vincent, P., and Janvin, C. (2003). A neural probabilistic language model.
J. Mach. Learn. Res. ,3, 1137–1155.
Bergstra, J., Breuleux, O., Bastien, F., Lamblin, P., Pascanu, R., Desjardins, G., Turian, J., Warde-
Farley, D., and Bengio, Y . (2010). Theano: a CPU and GPU math expression compiler. In
Proceedings of the Python for Scientiﬁc Computing Conference (SciPy) . Oral Presentation.
Boulanger-Lewandowski, N., Bengio, Y ., and Vincent, P. (2013). Audio chord recognition with
recurrent neural networks. In ISMIR .
Cho, K., van Merrienboer, B., Gulcehre, C., Bougares, F., Schwenk, H., and Bengio, Y . (2014a).
Learning phrase representations using RNN encoder-decoder for statistical machine translation.
InProceedings of the Empiricial Methods in Natural Language Processing (EMNLP 2014) . to
appear.
Cho, K., van Merri ¨enboer, B., Bahdanau, D., and Bengio, Y . (2014b). On the properties of neural
machine translation: Encoder–Decoder approaches. In Eighth Workshop on Syntax, Semantics
and Structure in Statistical Translation . to appear.
Devlin, J., Zbib, R., Huang, Z., Lamar, T., Schwartz, R., and Makhoul, J. (2014). Fast and robust
neural network joint models for statistical machine translation. In Association for Computational
Linguistics .
Forcada, M. L. and ˜Neco, R. P. (1997). Recursive hetero-associative memories for translation. In
J. Mira, R. Moreno-D ´ıaz, and J. Cabestany, editors, Biological and Artiﬁcial Computation: From
Neuroscience to Technology , volume 1240 of Lecture Notes in Computer Science , pages 453–462.
Springer Berlin Heidelberg.
Goodfellow, I., Warde-Farley, D., Mirza, M., Courville, A., and Bengio, Y . (2013). Maxout net-
works. In Proceedings of The 30th International Conference on Machine Learning , pages 1319–
1327.
Graves, A. (2012). Sequence transduction with recurrent neural networks. In Proceedings of the
29th International Conference on Machine Learning (ICML 2012) .
Graves, A. (2013). Generating sequences with recurrent neural networks. arXiv: 1308.0850
[cs.NE] .
Graves, A., Jaitly, N., and Mohamed, A.-R. (2013). Hybrid speech recognition with deep bidirec-
tional LSTM. In Automatic Speech Recognition and Understanding (ASRU), 2013 IEEE Work-
shop on , pages 273–278.
10
Published as a conference paper at ICLR 2015
Hermann, K. and Blunsom, P. (2014). Multilingual distributed representations without word align-
ment. In Proceedings of the Second International Conference on Learning Representations (ICLR
2014) .
Hochreiter, S. (1991). Untersuchungen zu dynamischen neuronalen Netzen. Diploma thesis, Institut
f¨ur Informatik, Lehrstuhl Prof. Brauer, Technische Universit ¨at M ¨unchen.
Hochreiter, S. and Schmidhuber, J. (1997). Long short-term memory. Neural Computation ,9(8),
1735–1780.
Kalchbrenner, N. and Blunsom, P. (2013). Recurrent continuous translation models. In Proceedings
of the ACL Conference on Empirical Methods in Natural Language Processing (EMNLP) , pages
1700–1709. Association for Computational Linguistics.
Koehn, P. (2010). Statistical Machine Translation . Cambridge University Press, New York, NY ,
USA.
Koehn, P., Och, F. J., and Marcu, D. (2003). Statistical phrase-based translation. In Proceedings
of the 2003 Conference of the North American Chapter of the Association for Computational
Linguistics on Human Language Technology - Volume 1 , NAACL ’03, pages 48–54, Stroudsburg,
PA, USA. Association for Computational Linguistics.
Pascanu, R., Mikolov, T., and Bengio, Y . (2013a). On the difﬁculty of training recurrent neural
networks. In ICML’2013 .
Pascanu, R., Mikolov, T., and Bengio, Y . (2013b). On the difﬁculty of training recurrent neural
networks. In Proceedings of the 30th International Conference on Machine Learning (ICML
2013) .
Pascanu, R., Gulcehre, C., Cho, K., and Bengio, Y . (2014). How to construct deep recurrent neural
networks. In Proceedings of the Second International Conference on Learning Representations
(ICLR 2014) .
Pouget-Abadie, J., Bahdanau, D., van Merri ¨enboer, B., Cho, K., and Bengio, Y . (2014). Overcoming
the curse of sentence length for neural machine translation using automatic segmentation. In
Eighth Workshop on Syntax, Semantics and Structure in Statistical Translation . to appear.
Schuster, M. and Paliwal, K. K. (1997). Bidirectional recurrent neural networks. Signal Processing,
IEEE Transactions on ,45(11), 2673–2681.
Schwenk, H. (2012). Continuous space translation models for phrase-based statistical machine
translation. In M. Kay and C. Boitet, editors, Proceedings of the 24th International Conference on
Computational Linguistics (COLIN) , pages 1071–1080. Indian Institute of Technology Bombay.
Schwenk, H., Dchelotte, D., and Gauvain, J.-L. (2006). Continuous space language models for
statistical machine translation. In Proceedings of the COLING/ACL on Main conference poster
sessions , pages 723–730. Association for Computational Linguistics.
Sutskever, I., Vinyals, O., and Le, Q. (2014). Sequence to sequence learning with neural networks.
InAdvances in Neural Information Processing Systems (NIPS 2014) .
Zeiler, M. D. (2012). ADADELTA: An adaptive learning rate method. arXiv: 1212.5701
[cs.LG] .
11
Published as a conference paper at ICLR 2015
A M ODEL ARCHITECTURE
A.1 A RCHITECTURAL CHOICES
The proposed scheme in Section 3 is a general framework where one can freely deﬁne, for instance,
the activation functions fof recurrent neural networks (RNN) and the alignment model a. Here, we
describe the choices we made for the experiments in this paper.
A.1.1 R ECURRENT NEURAL NETWORK
For the activation function fof an RNN, we use the gated hidden unit recently proposed by Cho
et al. (2014a). The gated hidden unit is an alternative to the conventional simple units such as an
element-wise tanh . This gated unit is similar to a long short-term memory (LSTM) unit proposed
earlier by Hochreiter and Schmidhuber (1997), sharing with it the ability to better model and learn
long-term dependencies. This is made possible by having computation paths in the unfolded RNN
for which the product of derivatives is close to 1. These paths allow gradients to ﬂow backward
easily without suffering too much from the vanishing effect (Hochreiter, 1991; Bengio et al. , 1994;
Pascanu et al. , 2013a). It is therefore possible to use LSTM units instead of the gated hidden unit
described here, as was done in a similar context by Sutskever et al. (2014).
The new state siof the RNN employing ngated hidden units8is computed by
si=f(si1;yi1;ci) = (1zi)si1+zi~si;
whereis an element-wise multiplication, and ziis the output of the update gates (see below). The
proposed updated state ~siis computed by
~si= tanh (We(yi1) +U[risi1] +Cci);
wheree(yi1)2Rmis anm-dimensional embedding of a word yi1, andriis the output of the
reset gates (see below). When yiis represented as a 1-of-Kvector,e(yi)is simply a column of an
embedding matrix E2RmK. Whenever possible, we omit bias terms to make the equations less
cluttered.
The update gates ziallow each hidden unit to maintain its previous activation, and the reset gates ri
control how much and what information from the previous state should be reset. We compute them
by
zi=(Wze(yi1) +Uzsi1+Czci);
ri=(Wre(yi1) +Ursi1+Crci);
where()is a logistic sigmoid function.
At each step of the decoder, we compute the output probability (Eq. (4)) as a multi-layered func-
tion (Pascanu et al. , 2014). We use a single hidden layer of maxout units (Goodfellow et al. , 2013)
and normalize the output probabilities (one for each word) with a softmax function (see Eq. (6)).
A.1.2 A LIGNMENT MODEL
The alignment model should be designed considering that the model needs to be evaluated TxTy
times for each sentence pair of lengths TxandTy. In order to reduce computation, we use a single-
layer multilayer perceptron such that
a(si1;hj) =v>
atanh (Wasi1+Uahj);
whereWa2Rnn;Ua2Rn2nandva2Rnare the weight matrices. Since Uahjdoes not
depend oni, we can pre-compute it in advance to minimize the computational cost.
8Here, we show the formula of the decoder. The same formula can be used in the encoder by simply
ignoring the context vector ciand the related terms.
12
Published as a conference paper at ICLR 2015
A.2 D ETAILED DESCRIPTION OF THE MODEL
A.2.1 E NCODER
In this section, we describe in detail the architecture of the proposed model (RNNsearch) used in the
experiments (see Sec. 4–5). From here on, we omit all bias terms in order to increase readability.
The model takes a source sentence of 1-of-K coded word vectors as input
x= (x1;:::;x Tx); xi2RKx
and outputs a translated sentence of 1-of-K coded word vectors
y= (y1;:::;y Ty); yi2RKy;
whereKxandKyare the vocabulary sizes of source and target languages, respectively. TxandTy
respectively denote the lengths of source and target sentences.
First, the forward states of the bidirectional recurrent neural network (BiRNN) are computed:
 !hi=(
(1 !zi) !hi1+ !zi !hi, ifi>0
0 , ifi= 0
where
 !hi= tanh !WExi+ !Uh !ri !hi1i
 !zi= !WzExi+ !Uz !hi1
 !ri= !WrExi+ !Ur !hi1
:
E2RmKxis the word embedding matrix. !W; !Wz; !Wr2Rnm, !U; !Uz; !Ur2Rnnare
weight matrices. mandnare the word embedding dimensionality and the number of hidden units,
respectively. ()is as usual a logistic sigmoid function.
The backward states ( h1;; hTx)are computed similarly. We share the word embedding matrix
Ebetween the forward and backward RNNs, unlike the weight matrices.
We concatenate the forward and backward states to to obtain the annotations (h1;h2;;hTx),
where
hi=" !hi hi#
(7)
A.2.2 D ECODER
The hidden state siof the decoder given the annotations from the encoder is computed by
si=(1zi)si1+zi~si;
where
~si= tanh (WEy i1+U[risi1] +Cci)
zi=(WzEyi1+Uzsi1+Czci)
ri=(WrEyi1+Ursi1+Crci)
Eis the word embedding matrix for the target language. W;W z;Wr2Rnm,U;Uz;Ur2Rnn,
andC;C z;Cr2Rn2nare weights. Again, mandnare the word embedding dimensionality
and the number of hidden units, respectively. The initial hidden state s0is computed by s0=
tanh
Ws h1
;whereWs2Rnn.
The context vector ciare recomputed at each step by the alignment model:
ci=TxX
j=1ijhj;
13
Published as a conference paper at ICLR 2015
Model Updates (105)Epochs Hours GPU Train NLL Dev. NLL
RNNenc-30 8.46 6.4 109 TITAN BLACK 28.1 53.0
RNNenc-50 6.00 4.5 108 Quadro K-6000 44.0 43.6
RNNsearch-30 4.71 3.6 113 TITAN BLACK 26.7 47.2
RNNsearch-50 2.88 2.2 111 Quadro K-6000 40.7 38.1
RNNsearch-50?6.67 5.0 252 Quadro K-6000 36.7 35.2
Table 2: Learning statistics and relevant information. Each update corresponds to updating the
parameters once using a single minibatch. One epoch is one pass through the training set. NLL is
the average conditional log-probabilities of the sentences in either the training set or the development
set. Note that the lengths of the sentences differ.
where
ij=exp (eij)PTx
k=1exp (eik)
eij=v>
atanh (Wasi1+Uahj);
andhjis thej-th annotation in the source sentence (see Eq. (7)). va2Rn0;Wa2Rn0nand
Ua2Rn02nare weight matrices. Note that the model becomes RNN Encoder–Decoder (Cho
et al. , 2014a), if we ﬁx cito !hTx.
With the decoder state si1, the context ciand the last generated word yi1, we deﬁne the probability
of a target word yias
p(yijsi;yi1;ci)/exp
y>
iWoti
;
where
ti=
max~ti;2j1;~ti;2j	>
j=1;:::;l
and~ti;kis thek-th element of a vector ~tiwhich is computed by
~ti=Uosi1+VoEyi1+Coci:
Wo2RKyl,Uo2R2ln,Vo2R2lmandCo2R2l2nare weight matrices. This can be under-
stood as having a deep output (Pascanu et al. , 2014) with a single maxout hidden layer (Goodfellow
et al. , 2013).
A.2.3 M ODEL SIZE
For all the models used in this paper, the size of a hidden layer nis 1000, the word embedding
dimensionality mis 620 and the size of the maxout hidden layer in the deep output lis 500. The
number of hidden units in the alignment model n0is 1000.
B T RAINING PROCEDURE
B.1 P ARAMETER INITIALIZATION
We initialized the recurrent weight matrices U;Uz;Ur; U; Uz; Ur; !U; !Uzand !Uras random or-
thogonal matrices. For WaandUa, we initialized them by sampling each element from the Gaussian
distribution of mean 0and variance 0:0012. All the elements of Vaand all the bias vectors were ini-
tialized to zero. Any other weight matrix was initialized by sampling from the Gaussian distribution
of mean 0and variance 0:012.
B.2 T RAINING
We used the stochastic gradient descent (SGD) algorithm. Adadelta (Zeiler, 2012) was used to
automatically adapt the learning rate of each parameter ( = 106and= 0:95). We explicitly
14
Published as a conference paper at ICLR 2015
normalized the L2-norm of the gradient of the cost function each time to be at most a predeﬁned
threshold of 1, when the norm was larger than the threshold (Pascanu et al. , 2013b). Each SGD
update direction was computed with a minibatch of 80 sentences.
At each update our implementation requires time proportional to the length of the longest sentence in
a minibatch. Hence, to minimize the waste of computation, before every 20-th update, we retrieved
1600 sentence pairs, sorted them according to the lengths and split them into 20 minibatches. The
training data was shufﬂed once before training and was traversed sequentially in this manner.
In Tables 2 we present the statistics related to training all the models used in the experiments.
C T RANSLATIONS OF LONG SENTENCES
Source An admitting privilege is the right of a doctor to admit a patient to a hospital or a medical centre
to carry out a diagnosis or a procedure, based on his status as a health care worker at a hospital.
Reference Le privil `ege d’admission est le droit d’un m ´edecin, en vertu de son statut de membre soignant
d’un h ˆopital, d’admettre un patient dans un h ˆopital ou un centre m ´edical aﬁn d’y d ´elivrer un
diagnostic ou un traitement.
RNNenc-50 Un privil `ege d’admission est le droit d’un m ´edecin de reconna ˆıtre un patient `a l’h ˆopital ou un
centre m ´edical d’un diagnostic ou de prendre un diagnostic en fonction de son ´etat de sant ´e.
RNNsearch-50 Un privil `ege d’admission est le droit d’un m ´edecin d’admettre un patient `a un h ˆopital ou un
centre m ´edical pour effectuer un diagnostic ou une proc ´edure, selon son statut de travailleur des
soins de sant ´e`a l’h ˆopital.
Google
TranslateUn privil `ege admettre est le droit d’un m ´edecin d’admettre un patient dans un h ˆopital ou un
centre m ´edical pour effectuer un diagnostic ou une proc ´edure, fond ´ee sur sa situation en tant
que travailleur de soins de sant ´e dans un h ˆopital.
Source This kind of experience is part of Disney’s efforts to ”extend the lifetime of its series and build
new relationships with audiences via digital platforms that are becoming ever more important,”
he added.
Reference Ce type d’exp ´erience entre dans le cadre des efforts de Disney pour ” ´etendre la dur ´ee de
vie de ses s ´eries et construire de nouvelles relations avec son public gr ˆace`a des plateformes
num´eriques qui sont de plus en plus importantes”, a-t-il ajout ´e.
RNNenc-50 Ce type d’exp ´erience fait partie des initiatives du Disney pour ”prolonger la dur ´ee de vie de
ses nouvelles et de d ´evelopper des liens avec les lecteurs num ´eriques qui deviennent plus com-
plexes.
RNNsearch-50 Ce genre d’exp ´erience fait partie des efforts de Disney pour ”prolonger la dur ´ee de vie de ses
s´eries et cr ´eer de nouvelles relations avec des publics via des plateformes num ´eriques de plus
en plus importantes”, a-t-il ajout ´e.
Google
TranslateCe genre d’exp ´erience fait partie des efforts de Disney `a “´etendre la dur ´ee de vie de sa s ´erie et
construire de nouvelles relations avec le public par le biais des plates-formes num ´eriques qui
deviennent de plus en plus important”, at-il ajout ´e.
Source In a press conference on Thursday, Mr Blair stated that there was nothing in this video that might
constitute a ”reasonable motive” that could lead to criminal charges being brought against the
mayor.
Reference En conf ´erence de presse, jeudi, M. Blair a afﬁrm ´e qu’il n’y avait rien dans cette vid ´eo qui puisse
constituer des ”motifs raisonnables” pouvant mener au d ´epˆot d’une accusation criminelle contre
le maire.
RNNenc-50 Lors de la conf ´erence de presse de jeudi, M. Blair a dit qu’il n’y avait rien dans cette vid ´eo qui
pourrait constituer une ”motivation raisonnable” pouvant entra ˆıner des accusations criminelles
port´ees contre le maire.
RNNsearch-50 Lors d’une conf ´erence de presse jeudi, M. Blair a d ´eclar ´e qu’il n’y avait rien dans cette vid ´eo qui
pourrait constituer un ”motif raisonnable” qui pourrait conduire `a des accusations criminelles
contre le maire.
Google
TranslateLors d’une conf ´erence de presse jeudi, M. Blair a d ´eclar ´e qu’il n’y avait rien dans cette vido
qui pourrait constituer un ”motif raisonnable” qui pourrait mener `a des accusations criminelles
portes contre le maire.
Table 3: The translations generated by RNNenc-50 and RNNsearch-50 from long source sentences
(30 words or more) selected from the test set. For each source sentence, we also show the gold-
standard translation. The translations by Google Translate were made on 27 August 2014.
15