4cbcf46bb80ecfbfedcd3e2872669d3aa96f5e27,stanfordnlp/models/common/char_model.py,CharacterLanguageModel,forward,#CharacterLanguageModel#,76

Before Change


        self.dropout = nn.Dropout(args["char_dropout"])

    def forward(self, chars, charoffsets, charlens, char_orig_idx):
        with torch.no_grad(): //TODO: remove
            embs = self.dropout(self.char_emb(chars))
            batch_size = embs.size(0)
            embs = pack_padded_sequence(embs, charlens, batch_first=True)
            output, _ = self.charlstm(embs, charlens, hx=(\
                    self.charlstm_h_init.expand(self.args["char_num_layers"], batch_size, self.args["char_hidden_dim"]).contiguous(), \
                    self.charlstm_c_init.expand(self.args["char_num_layers"], batch_size, self.args["char_hidden_dim"]).contiguous()))
            output = pad_packed_sequence(output, batch_first=True)[0]
            res = [output[i, offsets] for i, offsets in enumerate(charoffsets)]
            res = unsort(res, char_orig_idx)
            res = pack_sequence(res)
            if self.pad:
                res = pad_packed_sequence(res, batch_first=True)[0]
        
        return res

After Change


                      self.charlstm_c_init.expand(self.args["char_num_layers"], batch_size, self.args["char_hidden_dim"]).contiguous())
        output, hidden = self.charlstm(embs, charlens, hx=hidden)
        output = self.dropout(pad_packed_sequence(output, batch_first=True)[0])
        decoded = self.decoder(output)
        return output, hidden, decoded

    def get_representation(self, chars, charoffsets, charlens, char_orig_idx):
        with torch.no_grad(): //TODO: remove
            output, _, _ = self.forward(chars, charlens)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 6

Instances


Project Name: stanfordnlp/stanza
Commit Name: 4cbcf46bb80ecfbfedcd3e2872669d3aa96f5e27
Time: 2019-09-06
Author: zyh.thu@gmail.com
File Name: stanfordnlp/models/common/char_model.py
Class Name: CharacterLanguageModel
Method Name: forward


Project Name: explosion/thinc
Commit Name: 6d3ec6c28f32560121d93b8fcab2cf7924f59dc5
Time: 2020-01-02
Author: honnibal+gh@gmail.com
File Name: thinc/layers/pytorchwrapper.py
Class Name:
Method Name: forward


Project Name: batra-mlp-lab/visdial-challenge-starter-pytorch
Commit Name: b4a66d31cbd7dd296bb524f0512e7cfc0673495c
Time: 2019-04-10
Author: karandesai281196@gmail.com
File Name: data/extract_features_detectron.py
Class Name:
Method Name: detect_image