def _build(self, one_hot_input_sequence):
    """Builds the deep LSTM model sub-graph.

    Args:
      one_hot_input_sequence: A Tensor with the input sequence encoded as a
        one-hot representation. Its dimensions should be `[truncation_length,
        batch_size, output_size]`.

    Returns:
      Tuple of the Tensor of output logits for the batch, with dimensions
      `[truncation_length, batch_size, output_size]`, and the
      final state of the unrolled core,.
    """

    input_shape = one_hot_input_sequence.get_shape()
    batch_size = input_shape[1]

    batch_embed_module = snt.BatchApply(self._embed_module)
    input_sequence = batch_embed_module(one_hot_input_sequence)
    input_sequence = tf.nn.relu(input_sequence)

    initial_state = self._core.initial_state(batch_size)

    if self._use_dynamic_rnn:
      output_sequence, final_state = tf.nn.dynamic_rnn(
          cell=self._core,
          inputs=input_sequence,
          time_major=True,
          initial_state=initial_state)
    else:
      rnn_input_sequence = tf.unstack(input_sequence)
      output, final_state = tf.contrib.rnn.static_rnn(
          cell=self._core,
          inputs=rnn_input_sequence,
          initial_state=initial_state)
      output_sequence = tf.stack(output)

    batch_output_module = snt.BatchApply(self._output_module)
    output_sequence_logits = batch_output_module(output_sequence)

    return output_sequence_logits, final_state
def _build ( self , one_hot_input_sequence ) : input_shape = one_hot_input_sequence . get_shape ( ) batch_size = input_shape [ 1 ] batch_embed_module = snt . BatchApply ( self . _embed_module ) input_sequence = batch_embed_module ( one_hot_input_sequence ) input_sequence = tf . nn . relu ( input_sequence ) initial_state = self . _core . initial_state ( batch_size ) if self . _use_dynamic_rnn : output_sequence , final_state = tf . nn . dynamic_rnn ( cell = self . _core , inputs = input_sequence , time_major = True , initial_state = initial_state ) else : rnn_input_sequence = tf . unstack ( input_sequence ) output , final_state = tf . contrib . rnn . static_rnn ( cell = self . _core , inputs = rnn_input_sequence , initial_state = initial_state ) output_sequence = tf . stack ( output ) batch_output_module = snt . BatchApply ( self . _output_module ) output_sequence_logits = batch_output_module ( output_sequence ) return output_sequence_logits , final_state
Builds the deep LSTM model sub-graph.

    Args:
      one_hot_input_sequence: A Tensor with the input sequence encoded as a
        one-hot representation. Its dimensions should be `[truncation_length,
        batch_size, output_size]`.

    Returns:
      Tuple of the Tensor of output logits for the batch, with dimensions
      `[truncation_length, batch_size, output_size]`, and the
      final state of the unrolled core,.