models_mnist/executor.py [153:182]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  def _build_fact_encoder(self, inputs):
    """
    """

    # local alias
    params = self.params

    with tf.variable_scope(self.params['embed_scope'], reuse=True):
      embed_mat = tf.get_variable('embed_mat')

    # flatten
    # embed the words
    output = tf.nn.embedding_lookup(embed_mat, inputs['fact'])

    # pass through encoder
    cell = tf.contrib.rnn.BasicLSTMCell(params['text_embed_size'])

    # begin decoding
    for ii in range(0, params['num_layers']):
      # dynamic rnn
      output, states = tf.nn.dynamic_rnn(cell, output,
                                         sequence_length=inputs['fact_len'],
                                         dtype=tf.float32,
                                         scope='fact_layer_%d' % ii)

    # split roundwise
    fact_embed = states[1]
    text_dim = fact_embed.shape.as_list()[-1]
    fact_embed = tf.reshape(fact_embed, [-1, params['num_rounds'], text_dim])
    return fact_embed
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



models_vd/executor.py [117:146]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  def _build_fact_encoder(self, inputs):
    """
    """

    # local alias
    params = self.params

    with tf.variable_scope(self.params['embed_scope'], reuse=True):
      embed_mat = tf.get_variable('embed_mat')

    # flatten
    # embed the words
    output = tf.nn.embedding_lookup(embed_mat, inputs['fact'])

    # pass through encoder
    cell = tf.contrib.rnn.BasicLSTMCell(params['text_embed_size'])

    # begin decoding
    for ii in range(0, params['num_layers']):
      # dynamic rnn
      output, states = tf.nn.dynamic_rnn(cell, output,
                                         sequence_length=inputs['fact_len'],
                                         dtype=tf.float32,
                                         scope='fact_layer_%d' % ii)

    # split roundwise
    fact_embed = states[1]
    text_dim = fact_embed.shape.as_list()[-1]
    fact_embed = tf.reshape(fact_embed, [-1, params['num_rounds'], text_dim])
    return fact_embed
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



