1583c3304f0f071569424d36c206b875a705a026,a08_EntityNetwork/a3_entity_network.py,EntityNetwork,inference,#EntityNetwork#,62

Before Change


        // 1.input encoder
        // 1.1 embedding for story and query
        story_embedding = tf.nn.embedding_lookup(self.Embedding,self.story)  // [batch_size,story_length,sequence_length,embed_size]
        query_embedding=tf.nn.embedding_lookup(self.Embedding,self.query)    // [batch_size,sequence_length,embed_size]
        // 1.2 mask for story and query
        story_mask=tf.get_variable("story_mask",[self.sequence_length,1],initializer=tf.constant_initializer(1.0))
        query_mask=tf.get_variable("query_mask",[self.sequence_length,1],initializer=tf.constant_initializer(1.0))
        // 1.3 multiply of embedding and mask for story and query
        self.story_embedding=tf.multiply(story_embedding,story_mask)  // [batch_size,story_length,sequence_length,embed_size]
        self.query_embedding=tf.multiply(query_embedding,query_mask)  // [batch_size,sequence_length,embed_size]
        // 1.4 use bag of words to encoder story and query
        self.story_embedding=tf.reduce_sum(self.story_embedding,axis=2) //[batch_size,story_length,embed_size]
        self.query_embedding=tf.reduce_sum(self.query_embedding,axis=1)  //[batch_size,embed_size]

After Change


        main computation graph here: 1.input encoder 2.dynamic emeory 3.output layer 
        // 1.input encoder
        self.embedding_with_mask()
        if self.use_bi_lstm:
            self.input_encoder_bi_lstm()
        else:
            self.input_encoder_bow()
        // 2. dynamic emeory
        self.hidden_state=self.rnn_story() //[batch_size,block_size,hidden_size]. get hidden state after process the story

        // 3.output layer
        logits=self.output_module() //[batch_size,vocab_size]
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 5

Instances


Project Name: brightmart/text_classification
Commit Name: 1583c3304f0f071569424d36c206b875a705a026
Time: 2017-07-12
Author: brightmart@hotmail.com
File Name: a08_EntityNetwork/a3_entity_network.py
Class Name: EntityNetwork
Method Name: inference


Project Name: tensorlayer/tensorlayer
Commit Name: 2e0f0929df4b01b269962a6423d6cb78b6d3da17
Time: 2018-12-04
Author: dhsig552@163.com
File Name: tensorlayer/layers/inputs.py
Class Name: EmbeddingInput
Method Name: __init__


Project Name: tensorlayer/tensorlayer
Commit Name: e0cd4ddddb6b2813e53560017e88d9ef72efe8d4
Time: 2020-06-09
Author: rladhkstn8@gmail.com
File Name: tensorlayer/layers/embedding.py
Class Name: Word2vecEmbedding
Method Name: forward