nmt/model.py
def build_graph(self, hparams, scope=None):
    """Subclass must implement this method.

    Creates a sequence-to-sequence model with dynamic RNN decoder API.
    Args:
      hparams: Hyperparameter configurations.
      scope: VariableScope for the created subgraph; default "dynamic_seq2seq".

    Returns:
      A tuple of the form (logits, loss, final_context_state),
      where:
        logits: float32 Tensor [batch_size x num_decoder_symbols].
        loss: the total loss / batch_size.
        final_context_state: The final state of decoder RNN.

    Raises:
      ValueError: if encoder_type differs from mono and bi, or
        attention_option is not (luong | scaled_luong |
        bahdanau | normed_bahdanau).
    """
    utils.print_out("# creating %s graph ..." % self.mode)
    dtype = tf.float32

    with tf.variable_scope(scope or "dynamic_seq2seq", dtype=dtype):
      # Encoder
      encoder_outputs, encoder_state = self._build_encoder(hparams)

      ## Decoder
      logits, sample_id, final_context_state, step_log_probs = self._build_decoder(
          encoder_outputs, encoder_state, hparams)

      ## Loss
      if self.mode != tf.contrib.learn.ModeKeys.INFER:
        with tf.device(model_helper.get_device_str(0, #self.num_encoder_layers - 1,
                                                   self.num_gpus)):
          loss = self._compute_loss(logits)
      else:
        loss = None

      return logits, loss, final_context_state, sample_id, step_log_probs
Subclass must implement this method.

    Creates a sequence-to-sequence model with dynamic RNN decoder API.
    Args:
      hparams: Hyperparameter configurations.
      scope: VariableScope for the created subgraph; default "dynamic_seq2seq".

    Returns:
      A tuple of the form (logits, loss, final_context_state),
      where:
        logits: float32 Tensor [batch_size x num_decoder_symbols].
        loss: the total loss / batch_size.
        final_context_state: The final state of decoder RNN.

    Raises:
      ValueError: if encoder_type differs from mono and bi, or
        attention_option is not (luong | scaled_luong |
        bahdanau | normed_bahdanau).
    
Subclass must implement this method.
Creates a sequence-to-sequence model with dynamic RNN decoder API.
Subclass must implement this method . Creates a sequence - to - sequence model with dynamic RNN decoder API .
def build_graph(self, hparams, scope=None):
    utils.print_out("# creating %s graph ..." % self.mode)
    dtype = tf.float32
    with tf.variable_scope(scope or "dynamic_seq2seq", dtype=dtype):
      encoder_outputs, encoder_state = self._build_encoder(hparams)
      logits, sample_id, final_context_state, step_log_probs = self._build_decoder(
          encoder_outputs, encoder_state, hparams)
      if self.mode != tf.contrib.learn.ModeKeys.INFER:
        with tf.device(model_helper.get_device_str(0, 
                                                   self.num_gpus)):
          loss = self._compute_loss(logits)
      else:
        loss = None
      return logits, loss, final_context_state, sample_id, step_log_probs
def build_graph ( self , hparams , scope = None ) : utils . print_out ( "# creating %s graph ..." % self . mode ) dtype = tf . float32 with tf . variable_scope ( scope or "dynamic_seq2seq" , dtype = dtype ) : encoder_outputs , encoder_state = self . _build_encoder ( hparams ) logits , sample_id , final_context_state , step_log_probs = self . _build_decoder ( encoder_outputs , encoder_state , hparams ) if self . mode != tf . contrib . learn . ModeKeys . INFER : with tf . device ( model_helper . get_device_str ( 0 , self . num_gpus ) ) : loss = self . _compute_loss ( logits ) else : loss = None return logits , loss , final_context_state , sample_id , step_log_probs
Subclass must implement this method.
Subclass must implement this method .
"""Subclass must implement this method.

    Creates a sequence-to-sequence model with dynamic RNN decoder API.
    Args:
      hparams: Hyperparameter configurations.
      scope: VariableScope for the created subgraph; default "dynamic_seq2seq".

    Returns:
      A tuple of the form (logits, loss, final_context_state),
      where:
        logits: float32 Tensor [batch_size x num_decoder_symbols].
        loss: the total loss / batch_size.
        final_context_state: The final state of decoder RNN.

    Raises:
      ValueError: if encoder_type differs from mono and bi, or
        attention_option is not (luong | scaled_luong |
        bahdanau | normed_bahdanau).
    """ # Encoder ## Decoder ## Loss #self.num_encoder_layers - 1,
A tuple of the form (logits, loss, final_context_state),
where:
logits: float32 Tensor [batch_size x num_decoder_symbols].
loss: the total loss / batch_size.
final_context_state: The final state of decoder RNN.
A tuple of the form ( logits loss final_context_state ) where : logits : float32 Tensor [ batch_size x num_decoder_symbols ] . loss : the total loss / batch_size . final_context_state : The final state of decoder RNN .
if encoder_type differs from mono and bi, or
attention_option is not (luong | scaled_luong |
bahdanau | normed_bahdanau).
if encoder_type differs from mono and bi or attention_option is not ( luong | scaled_luong | bahdanau | normed_bahdanau ) .
ValueError
self
hparams
None
scope
VariableScope for the created subgraph; default "dynamic_seq2seq".
VariableScope for the created subgraph ; default " dynamic_seq2seq " .