5acb5a785b9ed60743e6f687a96bd92dd4e88578,allennlp/modules/seq2vec_encoders/pytorch_seq2vec_wrapper.py,PytorchSeq2VecWrapper,forward,#PytorchSeq2VecWrapper#Any#Any#Any#,59

Before Change


        // running the RNN we zero out the corresponding rows in the result.

        // First count how many sequences are empty.
        batch_size = mask.size()[0]
        num_valid = torch.sum(mask[:, 0]).int().data[0]

        // Force every sequence to be length at least one. Need to `.clone()` the mask

After Change


            zeros = state.data.new(num_layers_times_directions,
                                   batch_size - num_valid,
                                   encoding_dim).fill_(0)
            state = torch.cat([state, zeros], 1)

        // Restore the original indices and return the final state of the
        // top layer. Pytorch"s recurrent layers return state in the form
        // (num_layers * num_directions, batch_size, hidden_size) regardless
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: allenai/allennlp
Commit Name: 5acb5a785b9ed60743e6f687a96bd92dd4e88578
Time: 2017-11-29
Author: markn@allenai.org
File Name: allennlp/modules/seq2vec_encoders/pytorch_seq2vec_wrapper.py
Class Name: PytorchSeq2VecWrapper
Method Name: forward


Project Name: OpenNMT/OpenNMT-py
Commit Name: c13a558767cbc19b612968eb4d01a1f26d5df688
Time: 2017-06-10
Author: wangqian5730@gmail.com
File Name: onmt/Models.py
Class Name: NMTModel
Method Name: _fix_enc_hidden


Project Name: OpenNMT/OpenNMT-py
Commit Name: 31e7f40c3381aac21e8665d0b5706bceddd9de94
Time: 2017-06-25
Author: srush@sum1gpu01.rc.fas.harvard.edu
File Name: onmt/Models.py
Class Name: Decoder
Method Name: forward