def rand_init(self, init_char_embedding=True, init_word_embedding=False):
        """
        random initialization

        args:
            init_char_embedding: random initialize char embedding or not
            init_word_embedding: random initialize word embedding or not
        """
        
        if init_char_embedding:
            utils.init_embedding(self.char_embeds.weight)
        if init_word_embedding:
            utils.init_embedding(self.word_embeds.weight)
        if self.if_highway:
            self.forw2char.rand_init()
            self.back2char.rand_init()
            self.forw2word.rand_init()
            self.back2word.rand_init()
            self.fb2char.rand_init()
        utils.init_lstm(self.forw_char_lstm)
        utils.init_lstm(self.back_char_lstm)
        utils.init_lstm(self.word_lstm)
        utils.init_linear(self.char_pre_train_out)
        utils.init_linear(self.word_pre_train_out)
        for crf in self.crflist:
            crf.rand_init()
Exemple #2
0
    def rand_init(self, init_embedding=False):
        """
        random initialization

        args:
            init_embedding: random initialize embedding or not
        """
        if init_embedding:
            utils.init_embedding(self.word_embeds.weight)
        utils.init_lstm(self.lstm)
Exemple #3
0
    def rand_init(self, init_embedding=False):
        """
        random initialization

        args:
            init_embedding: random initialize embedding or not
        """
        if init_embedding:
            utils.init_embedding(self.word_embeds.weight)
        utils.init_lstm(self.lstm)
        self.crf.rand_init()
Exemple #4
0
    def rand_init(self, init_word_embedding=False, init_action_embedding=True, init_relation_embedding=True):

        if init_word_embedding:
            utils.init_embedding(self.word_embeds.weight)
        if init_action_embedding:
            utils.init_embedding(self.action_embeds.weight)
        if init_relation_embedding:
            utils.init_embedding(self.relation_embeds.weight)

        if self.use_spelling:
            utils.init_embedding(self.char_embeds.weight)
        if self.use_spelling and self.char_structure == 'lstm':
            utils.init_lstm(self.char_bi_lstm)

        utils.init_linear(self.lstms_output_2_softmax)
        utils.init_linear(self.output_2_act)
        utils.init_linear(self.entity_2_output)

        utils.init_lstm(self.lstm)
        utils.init_lstm_cell(self.buffer_lstm)
        utils.init_lstm_cell(self.action_lstm)
        utils.init_lstm_cell(self.stack_lstm)
        utils.init_lstm_cell(self.output_lstm)
        utils.init_lstm_cell(self.entity_forward_lstm)
        utils.init_lstm_cell(self.entity_backward_lstm)
Exemple #5
0
    def rand_init(self):
        """
        random initialization

        args:
            init_char_embedding: random initialize char embedding or not

        """

        utils.init_embedding(self.char_embeds.weight)
        if self.char_lstm:
            utils.init_lstm(self.forw_char_lstm)
            utils.init_lstm(self.back_char_lstm)
            utils.init_lstm(self.word_lstm_lm)
            utils.init_linear(self.char_pre_train_out)
            utils.init_linear(self.word_pre_train_out)
            if self.if_highway:
                self.forw2char.rand_init()
                self.back2char.rand_init()
                self.forw2word.rand_init()
                self.back2word.rand_init()
                self.fb2char.rand_init()
        else:
            utils.init_lstm(self.word_lstm_cnn)
    def rand_init(self, init_char_embedding=False, init_word_embedding=False, init_bichar_embedding=False):
        """
        random initialization

        args:
            init_embedding: random initialize embedding or not
        """
        if init_char_embedding:
            utils.init_embedding(self.char_embeds.weight)
        if init_bichar_embedding:
            utils.init_embedding(self.bichar_embeds.weight)
        if init_word_embedding:
            utils.init_embedding(self.word_embeds.weight)
        self.crf.rand_init()
 def rand_init_embedding(self):
     """
     random initialize char-level embedding
     """
     utils.init_embedding(self.char_embeds.weight)
Exemple #8
0
 def rand_init_embedding(self):
     utils.init_embedding(self.word_embeds.weight)
Exemple #9
0
 def rand_init_embedding(self):
     utils.init_embedding(self.word_embeds.weight)