Example #1
0
 def step(state_tup, inp):
     """Single step of the improved Neural GPU."""
     state, _ = state_tup
     x = state
     for layer in range(hparams.num_hidden_layers):
         x, new_loss = common_layers.diagonal_conv_gru(
             x, (hparams.kernel_height, hparams.kernel_width),
             hparams.hidden_size,
             dropout=hparams.dropout,
             name="dcgru_%d" % layer)
     # Padding input is zeroed-out in the modality, we check this by summing.
     padding_inp = tf.less(tf.reduce_sum(tf.abs(inp), axis=[1, 2]), 0.00001)
     new_state = tf.where(padding_inp, state, x)  # No-op where inp is padding.
     return new_state, new_loss
Example #2
0
 def step(state_tup, inp):
   """Single step of the improved Neural GPU."""
   state, _ = state_tup
   x = state
   for layer in xrange(hparams.num_hidden_layers):
     x, new_loss = common_layers.diagonal_conv_gru(
         x, (hparams.kernel_height, hparams.kernel_width),
         hparams.hidden_size,
         dropout=hparams.dropout,
         name="dcgru_%d" % layer)
   # Padding input is zeroed-out in the modality, we check this by summing.
   padding_inp = tf.less(tf.reduce_sum(tf.abs(inp), axis=[1, 2]), 0.00001)
   new_state = tf.where(padding_inp, state, x)  # No-op where inp is padding.
   return new_state, new_loss