Apply dropout before the residual connection
@@ -26,10 +26,10 @@ def build_cell(num_layers,
for l in range(num_layers):
cell = cell_class(num_units)
- if residual_connections and l > 0:
- cell = tf.contrib.rnn.ResidualWrapper(cell)
if mode == tf.estimator.ModeKeys.TRAIN and dropout > 0.0:
cell = tf.contrib.rnn.DropoutWrapper(cell, output_keep_prob=1.0 - dropout)
+ if residual_connections and l > 0:
+ cell = tf.contrib.rnn.ResidualWrapper(cell)
cells.append(cell)
if len(cells) == 1:
