text_model/model_skeleton.py
def _init_word_embedding(self):
        """
        Init word embeddings for text token ids.
        """
        ## use pre-trained word embedding or not
        self.pre_trained_wembed = self.options.get("pre_trained_wembed", None)
        shape = [self.vocab_size, self.wembed_dim]
        with tf.variable_scope("word_embeddings"), tf.device("/cpu:0"):
            if self.pre_trained_wembed:
                self.wembed_init = tf.placeholder(dtype=TF_DTYPE, shape=shape)
                shape = None
                ## finetune pre-trained wembed or not
                trainable = self.options.get("finetune_wembed", False)
            else:
                self.wembed_init = tf.random_normal_initializer()
                trainable = True

            self.word_embed = tf.get_variable("embeddings", shape=shape,
                                              dtype=TF_DTYPE, initializer=self.wembed_init,
                                              trainable=trainable)

        Init word embeddings for text token ids.
        
Init word embeddings for text token ids.
Init word embeddings for text token ids .
def _init_word_embedding(self):
        self.pre_trained_wembed = self.options.get("pre_trained_wembed", None)
        shape = [self.vocab_size, self.wembed_dim]
        with tf.variable_scope("word_embeddings"), tf.device("/cpu:0"):
            if self.pre_trained_wembed:
                self.wembed_init = tf.placeholder(dtype=TF_DTYPE, shape=shape)
                shape = None
                trainable = self.options.get("finetune_wembed", False)
            else:
                self.wembed_init = tf.random_normal_initializer()
                trainable = True
            self.word_embed = tf.get_variable("embeddings", shape=shape,
                                              dtype=TF_DTYPE, initializer=self.wembed_init,
                                              trainable=trainable)
def _init_word_embedding ( self ) : self . pre_trained_wembed = self . options . get ( "pre_trained_wembed" , None ) shape = [ self . vocab_size , self . wembed_dim ] with tf . variable_scope ( "word_embeddings" ) , tf . device ( "/cpu:0" ) : if self . pre_trained_wembed : self . wembed_init = tf . placeholder ( dtype = TF_DTYPE , shape = shape ) shape = None trainable = self . options . get ( "finetune_wembed" , False ) else : self . wembed_init = tf . random_normal_initializer ( ) trainable = True self . word_embed = tf . get_variable ( "embeddings" , shape = shape , dtype = TF_DTYPE , initializer = self . wembed_init , trainable = trainable )
Init word embeddings for text token ids.
Init word embeddings for text token ids .
"""
        Init word embeddings for text token ids.
        """ ## use pre-trained word embedding or not ## finetune pre-trained wembed or not
self