b9e27136a5e80850df7859b8f3ca23d396f1b009,snorkel/learning/pytorch/rnn/lstm.py,LSTM,forward,#LSTM#Any#Any#,22

Before Change


        outs = []
        for i in range(X.size(0)):
            outs.append(output[i, seq_lengths[i] - 1,:])
        output = torch.stack(outs, dim=0)
        return self.output_layer(self.dropout_layer(output))
    
    def initalize_hidden_state(self, batch_size):
        return (

After Change



        seq_lengths, perm_idx = seq_lengths.sort(0, descending=True)
        X = X[perm_idx, :]
        inv_perm_idx = torch.tensor([i for i, _ in sorted(enumerate(perm_idx), key=lambda idx: idx[1])], dtype=torch.long)

        encoded_X = self.embedding(X)
        encoded_X = pack_padded_sequence(encoded_X, seq_lengths, batch_first=True)
        _, (ht, _) = self.lstm(encoded_X, hidden_state)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: snorkel-team/snorkel
Commit Name: b9e27136a5e80850df7859b8f3ca23d396f1b009
Time: 2018-05-04
Author: stephenhbach@gmail.com
File Name: snorkel/learning/pytorch/rnn/lstm.py
Class Name: LSTM
Method Name: forward


Project Name: stanfordnlp/stanza
Commit Name: db7b74579181f9cbae3583f447d83148714a1c3d
Time: 2020-06-15
Author: horatio@gmail.com
File Name: stanza/models/classifiers/cnn_classifier.py
Class Name: CNNClassifier
Method Name: forward


Project Name: rusty1s/pytorch_geometric
Commit Name: 4017d2beea471b593ae169f17bc08d4c236c0b46
Time: 2019-08-01
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/read/obj.py
Class Name:
Method Name: read_obj