lm1b/model/model_nodes.py
def _attach_projection_nodes(input, hparams=None):
  """
  Project LSTM outputs to sparse vectors / word predictions
  :param input: lstm outputs
  :param hparams:
  :return: tensor shaped [?,vocab_size]
  """
  softmax_w = create_sharded_weights((hparams.vocab_size / NUM_SHARDS, hparams.word_embedding_size),
                                     num_shards=NUM_SHARDS,
                                     concat_dim=1)
  softmax_w = tf.reshape(softmax_w, shape=(-1, hparams.word_embedding_size))
  softmax_b = tf.get_variable('b', shape=(hparams.vocab_size))

  logits = tf.nn.bias_add(tf.matmul(input, softmax_w, transpose_b=True), softmax_b, data_format="NHWC")
  softmax = tf.nn.softmax(logits)
  return logits, softmax

  Project LSTM outputs to sparse vectors / word predictions
  :param input: lstm outputs
  :param hparams:
  :return: tensor shaped [?,vocab_size]
  
Project LSTM outputs to sparse vectors / word predictions
Project LSTM outputs to sparse vectors / word predictions
def _attach_projection_nodes(input, hparams=None):
  softmax_w = create_sharded_weights((hparams.vocab_size / NUM_SHARDS, hparams.word_embedding_size),
                                     num_shards=NUM_SHARDS,
                                     concat_dim=1)
  softmax_w = tf.reshape(softmax_w, shape=(-1, hparams.word_embedding_size))
  softmax_b = tf.get_variable('b', shape=(hparams.vocab_size))
  logits = tf.nn.bias_add(tf.matmul(input, softmax_w, transpose_b=True), softmax_b, data_format="NHWC")
  softmax = tf.nn.softmax(logits)
  return logits, softmax
def _attach_projection_nodes ( input , hparams = None ) : softmax_w = create_sharded_weights ( ( hparams . vocab_size / NUM_SHARDS , hparams . word_embedding_size ) , num_shards = NUM_SHARDS , concat_dim = 1 ) softmax_w = tf . reshape ( softmax_w , shape = ( - 1 , hparams . word_embedding_size ) ) softmax_b = tf . get_variable ( 'b' , shape = ( hparams . vocab_size ) ) logits = tf . nn . bias_add ( tf . matmul ( input , softmax_w , transpose_b = True ) , softmax_b , data_format = "NHWC" ) softmax = tf . nn . softmax ( logits ) return logits , softmax
Project LSTM outputs to sparse vectors / word predictions
Project LSTM outputs to sparse vectors / word predictions
"""
  Project LSTM outputs to sparse vectors / word predictions
  :param input: lstm outputs
  :param hparams:
  :return: tensor shaped [?,vocab_size]
  """
tensor shaped [?,vocab_size]
tensor shaped [ ? vocab_size ]
input
None
hparams
None