(self)
return inputs
Add embedding layer. that maps from vocabulary to vectors.

        Returns:
            inputs: shape(b_sz, tstp, emb_sz), fetched input
Add embedding layer. that maps from vocabulary to vectors.
Add embedding layer . that maps from vocabulary to vectors .
def add_embedding(self):
        """Add embedding layer. that maps from vocabulary to vectors.

        Returns:
            inputs: shape(b_sz, tstp, emb_sz), fetched input
        """
        if self.config.pre_trained:
            embed_dic = helper.readEmbedding(self.config.embed_path+str(self.config.embed_size))  #embedding.50 for 50 dim embedding
            embed_matrix = helper.mkEmbedMatrix(embed_dic, self.vocab.word_to_index)
            self.embedding = tf.Variable(embed_matrix, 'Embedding')
        else:
            self.embedding = tf.get_variable(
              'Embedding',
              [len(self.vocab), self.config.embed_size], trainable=True)
        inputs = tf.nn.embedding_lookup(self.embedding, self.ph_input)  # shape(b_sz, tstp, emb_sz)
        return inputs
def add_embedding ( self ) : if self . config . pre_trained : embed_dic = helper . readEmbedding ( self . config . embed_path + str ( self . config . embed_size ) ) #embedding.50 for 50 dim embedding embed_matrix = helper . mkEmbedMatrix ( embed_dic , self . vocab . word_to_index ) self . embedding = tf . Variable ( embed_matrix , 'Embedding' ) else : self . embedding = tf . get_variable ( 'Embedding' , [ len ( self . vocab ) , self . config . embed_size ] , trainable = True ) inputs = tf . nn . embedding_lookup ( self . embedding , self . ph_input ) # shape(b_sz, tstp, emb_sz) return inputs