nmt/model.py
def _build_decoder_cell(self, hparams, encoder_outputs, encoder_state,
                          source_sequence_length):
    """Build an RNN cell that can be used by decoder."""
    # We only make use of encoder_outputs in attention-based models
    if hparams.attention:
      raise ValueError("BasicModel doesn't support attention.")

    cell = model_helper.create_rnn_cell(
        unit_type=hparams.unit_type,
        num_units=hparams.num_units,
        num_layers=self.num_decoder_layers,
        num_residual_layers=self.num_decoder_residual_layers,
        forget_bias=hparams.forget_bias,
        dropout=hparams.dropout,
        num_gpus=self.num_gpus,
        mode=self.mode,
        single_cell_fn=self.single_cell_fn)

    # For beam search, we need to replicate encoder infos beam_width times
    if self.mode == tf.contrib.learn.ModeKeys.INFER and hparams.beam_width > 0:
      decoder_initial_state = tf.contrib.seq2seq.tile_batch(
          encoder_state, multiplier=hparams.beam_width)
    else:
      decoder_initial_state = encoder_state
    
    return cell, decoder_initial_state
Build an RNN cell that can be used by decoder.
Build an RNN cell that can be used by decoder.
Build an RNN cell that can be used by decoder .
def _build_decoder_cell(self, hparams, encoder_outputs, encoder_state,
                          source_sequence_length):
    if hparams.attention:
      raise ValueError("BasicModel doesn't support attention.")
    cell = model_helper.create_rnn_cell(
        unit_type=hparams.unit_type,
        num_units=hparams.num_units,
        num_layers=self.num_decoder_layers,
        num_residual_layers=self.num_decoder_residual_layers,
        forget_bias=hparams.forget_bias,
        dropout=hparams.dropout,
        num_gpus=self.num_gpus,
        mode=self.mode,
        single_cell_fn=self.single_cell_fn)
    if self.mode == tf.contrib.learn.ModeKeys.INFER and hparams.beam_width > 0:
      decoder_initial_state = tf.contrib.seq2seq.tile_batch(
          encoder_state, multiplier=hparams.beam_width)
    else:
      decoder_initial_state = encoder_state
    return cell, decoder_initial_state
def _build_decoder_cell ( self , hparams , encoder_outputs , encoder_state , source_sequence_length ) : if hparams . attention : raise ValueError ( "BasicModel doesn't support attention." ) cell = model_helper . create_rnn_cell ( unit_type = hparams . unit_type , num_units = hparams . num_units , num_layers = self . num_decoder_layers , num_residual_layers = self . num_decoder_residual_layers , forget_bias = hparams . forget_bias , dropout = hparams . dropout , num_gpus = self . num_gpus , mode = self . mode , single_cell_fn = self . single_cell_fn ) if self . mode == tf . contrib . learn . ModeKeys . INFER and hparams . beam_width > 0 : decoder_initial_state = tf . contrib . seq2seq . tile_batch ( encoder_state , multiplier = hparams . beam_width ) else : decoder_initial_state = encoder_state return cell , decoder_initial_state
Build an RNN cell that can be used by decoder.
Build an RNN cell that can be used by decoder .
"""Build an RNN cell that can be used by decoder.""" # We only make use of encoder_outputs in attention-based models # For beam search, we need to replicate encoder infos beam_width times
self
hparams
encoder_outputs
encoder_state
source_sequence_length