(self,
                 inputs,
                 lengths=None,
                 initial_state=None)
return RnnNadeStateTuple(b_enc, b_dec, final_rnn_state)
Computes the state of the RNN-NADE (NADE bias parameters and RNN state).

    Args:
      inputs: A batch of sequences to compute the state from, sized
          `[batch_size, max(lengths), num_dims]` or `[batch_size, num_dims]`.
      lengths: The length of each sequence, sized `[batch_size]`.
      initial_state: An RnnNadeStateTuple, the initial state of the RNN-NADE, or
          None if the zero state should be used.

    Returns:
      final_state: An RnnNadeStateTuple, the final state of the RNN-NADE.
Computes the state of the RNN-NADE (NADE bias parameters and RNN state).
Computes the state of the RNN - NADE ( NADE bias parameters and RNN state ) .
def _get_state(self,
                 inputs,
                 lengths=None,
                 initial_state=None):
    """Computes the state of the RNN-NADE (NADE bias parameters and RNN state).

    Args:
      inputs: A batch of sequences to compute the state from, sized
          `[batch_size, max(lengths), num_dims]` or `[batch_size, num_dims]`.
      lengths: The length of each sequence, sized `[batch_size]`.
      initial_state: An RnnNadeStateTuple, the initial state of the RNN-NADE, or
          None if the zero state should be used.

    Returns:
      final_state: An RnnNadeStateTuple, the final state of the RNN-NADE.
    """
    batch_size = int(inputs.shape[0])

    if lengths is None:
      lengths = tf.tile(tf.shape(inputs)[1:2], [batch_size])
    if initial_state is None:
      initial_rnn_state = self._get_rnn_zero_state(batch_size)
    else:
      initial_rnn_state = initial_state.rnn_state

    helper = contrib_seq2seq.TrainingHelper(
        inputs=inputs, sequence_length=lengths)

    decoder = contrib_seq2seq.BasicDecoder(
        cell=self._rnn_cell,
        helper=helper,
        initial_state=initial_rnn_state,
        output_layer=self._fc_layer)

    final_outputs, final_rnn_state = contrib_seq2seq.dynamic_decode(
        decoder)[0:2]

    # Flatten time dimension.
    final_outputs_flat = magenta.common.flatten_maybe_padded_sequences(
        final_outputs.rnn_output, lengths)

    b_enc, b_dec = tf.split(
        final_outputs_flat, [self._nade.num_hidden, self._nade.num_dims],
        axis=1)

    return RnnNadeStateTuple(b_enc, b_dec, final_rnn_state)
def _get_state ( self , inputs , lengths = None , initial_state = None ) : batch_size = int ( inputs . shape [ 0 ] ) if lengths is None : lengths = tf . tile ( tf . shape ( inputs ) [ 1 : 2 ] , [ batch_size ] ) if initial_state is None : initial_rnn_state = self . _get_rnn_zero_state ( batch_size ) else : initial_rnn_state = initial_state . rnn_state helper = contrib_seq2seq . TrainingHelper ( inputs = inputs , sequence_length = lengths ) decoder = contrib_seq2seq . BasicDecoder ( cell = self . _rnn_cell , helper = helper , initial_state = initial_rnn_state , output_layer = self . _fc_layer ) final_outputs , final_rnn_state = contrib_seq2seq . dynamic_decode ( decoder ) [ 0 : 2 ] # Flatten time dimension. final_outputs_flat = magenta . common . flatten_maybe_padded_sequences ( final_outputs . rnn_output , lengths ) b_enc , b_dec = tf . split ( final_outputs_flat , [ self . _nade . num_hidden , self . _nade . num_dims ] , axis = 1 ) return RnnNadeStateTuple ( b_enc , b_dec , final_rnn_state )