(x, model_hparams, vocab_size, name, reuse)
Internal bottom transformation.
Internal bottom transformation.
Internal bottom transformation .
def bottom_simple(x, model_hparams, vocab_size, name, reuse):
  """Internal bottom transformation."""
  with tf.variable_scope(name, reuse=reuse):
    var = _get_weights(model_hparams, vocab_size)
    x = common_layers.dropout_no_scaling(
        x, 1.0 - model_hparams.symbol_dropout)
    # Add together the embeddings for each tuple position.
    ret = tf.add_n([
        tf.gather(var, x[:, :, :, i] + sum(vocab_size[:i])) *
        tf.expand_dims(tf.to_float(tf.not_equal(x[:, :, :, i], 0)), -1)
        for i in range(len(vocab_size))
    ])
    if model_hparams.multiply_embedding_mode == 'sqrt_depth':
      ret *= model_hparams.hidden_size**0.5
    return ret
def bottom_simple ( x , model_hparams , vocab_size , name , reuse ) : with tf . variable_scope ( name , reuse = reuse ) : var = _get_weights ( model_hparams , vocab_size ) x = common_layers . dropout_no_scaling ( x , 1.0 - model_hparams . symbol_dropout ) # Add together the embeddings for each tuple position. ret = tf . add_n ( [ tf . gather ( var , x [ : , : , : , i ] + sum ( vocab_size [ : i ] ) ) * tf . expand_dims ( tf . to_float ( tf . not_equal ( x [ : , : , : , i ] , 0 ) ) , - 1 ) for i in range ( len ( vocab_size ) ) ] ) if model_hparams . multiply_embedding_mode == 'sqrt_depth' : ret *= model_hparams . hidden_size ** 0.5 return ret