nmt/model.py
def _build_bidirectional_rnn(self, inputs, sequence_length,
                               dtype, hparams,
                               num_bi_layers,
                               num_bi_residual_layers,
                               base_gpu=0):
    """Create and call biddirectional RNN cells.

    Args:
      num_residual_layers: Number of residual layers from top to bottom. For
        example, if `num_bi_layers=4` and `num_residual_layers=2`, the last 2 RNN
        layers in each RNN cell will be wrapped with `ResidualWrapper`.
      base_gpu: The gpu device id to use for the first forward RNN layer. The
        i-th forward RNN layer will use `(base_gpu + i) % num_gpus` as its
        device id. The `base_gpu` for backward RNN cell is `(base_gpu +
        num_bi_layers)`.

    Returns:
      The concatenated bidirectional output and the bidirectional RNN cell"s
      state.
    """
    # Construct forward and backward cells
    fw_cell = self._build_encoder_cell(hparams,
                                       num_bi_layers,
                                       num_bi_residual_layers,
                                       base_gpu=base_gpu)
    bw_cell = self._build_encoder_cell(hparams,
                                       num_bi_layers,
                                       num_bi_residual_layers,
                                       base_gpu=(base_gpu + num_bi_layers))

    bi_outputs, bi_state = tf.nn.bidirectional_dynamic_rnn(
        fw_cell,
        bw_cell,
        inputs,
        dtype=dtype,
        sequence_length=sequence_length,
        time_major=self.time_major,
        swap_memory=True)

    return tf.concat(bi_outputs, -1), bi_state
Create and call biddirectional RNN cells.

    Args:
      num_residual_layers: Number of residual layers from top to bottom. For
        example, if `num_bi_layers=4` and `num_residual_layers=2`, the last 2 RNN
        layers in each RNN cell will be wrapped with `ResidualWrapper`.
      base_gpu: The gpu device id to use for the first forward RNN layer. The
        i-th forward RNN layer will use `(base_gpu + i) % num_gpus` as its
        device id. The `base_gpu` for backward RNN cell is `(base_gpu +
        num_bi_layers)`.

    Returns:
      The concatenated bidirectional output and the bidirectional RNN cell"s
      state.
    
Create and call biddirectional RNN cells.
Create and call biddirectional RNN cells .
def _build_bidirectional_rnn(self, inputs, sequence_length,
                               dtype, hparams,
                               num_bi_layers,
                               num_bi_residual_layers,
                               base_gpu=0):
    fw_cell = self._build_encoder_cell(hparams,
                                       num_bi_layers,
                                       num_bi_residual_layers,
                                       base_gpu=base_gpu)
    bw_cell = self._build_encoder_cell(hparams,
                                       num_bi_layers,
                                       num_bi_residual_layers,
                                       base_gpu=(base_gpu + num_bi_layers))
    bi_outputs, bi_state = tf.nn.bidirectional_dynamic_rnn(
        fw_cell,
        bw_cell,
        inputs,
        dtype=dtype,
        sequence_length=sequence_length,
        time_major=self.time_major,
        swap_memory=True)
    return tf.concat(bi_outputs, -1), bi_state
def _build_bidirectional_rnn ( self , inputs , sequence_length , dtype , hparams , num_bi_layers , num_bi_residual_layers , base_gpu = 0 ) : fw_cell = self . _build_encoder_cell ( hparams , num_bi_layers , num_bi_residual_layers , base_gpu = base_gpu ) bw_cell = self . _build_encoder_cell ( hparams , num_bi_layers , num_bi_residual_layers , base_gpu = ( base_gpu + num_bi_layers ) ) bi_outputs , bi_state = tf . nn . bidirectional_dynamic_rnn ( fw_cell , bw_cell , inputs , dtype = dtype , sequence_length = sequence_length , time_major = self . time_major , swap_memory = True ) return tf . concat ( bi_outputs , - 1 ) , bi_state
Create and call biddirectional RNN cells.
Create and call biddirectional RNN cells .
"""Create and call biddirectional RNN cells.

    Args:
      num_residual_layers: Number of residual layers from top to bottom. For
        example, if `num_bi_layers=4` and `num_residual_layers=2`, the last 2 RNN
        layers in each RNN cell will be wrapped with `ResidualWrapper`.
      base_gpu: The gpu device id to use for the first forward RNN layer. The
        i-th forward RNN layer will use `(base_gpu + i) % num_gpus` as its
        device id. The `base_gpu` for backward RNN cell is `(base_gpu +
        num_bi_layers)`.

    Returns:
      The concatenated bidirectional output and the bidirectional RNN cell"s
      state.
    """ # Construct forward and backward cells
The concatenated bidirectional output and the bidirectional RNN cell"s
state.
The concatenated bidirectional output and the bidirectional RNN cell " s state .
self
inputs
sequence_length
dtype
hparams
num_bi_layers
num_bi_residual_layers
base_gpu
The gpu device id to use for the first forward RNN layer. The
i-th forward RNN layer will use `(base_gpu + i) % num_gpus` as its
device id. The `base_gpu` for backward RNN cell is `(base_gpu +
num_bi_layers)`.
The gpu device id to use for the first forward RNN layer . The i - th forward RNN layer will use ` ( base_gpu + i ) % num_gpus ` as its device id . The ` base_gpu ` for backward RNN cell is ` ( base_gpu + num_bi_layers ) ` .
num_residual_layers
Number of residual layers from top to bottom. For
example, if `num_bi_layers=4` and `num_residual_layers=2`, the last 2 RNN
layers in each RNN cell will be wrapped with `ResidualWrapper`.
Number of residual layers from top to bottom . For example if ` num_bi_layers = 4 ` and ` num_residual_layers = 2 ` the last 2 RNN layers in each RNN cell will be wrapped with ` ResidualWrapper ` .