c13a558767cbc19b612968eb4d01a1f26d5df688,onmt/Models.py,NMTModel,_fix_enc_hidden,#NMTModel#Any#,132
Before Change
if self.encoder.num_directions == 2:
return h.view(h.size(0) // 2, 2, h.size(1), h.size(2)) \
.transpose(1, 2).contiguous() \
.view(h.size(0) // 2, h.size(1), h.size(2) * 2)
else:
return h
After Change
def _fix_enc_hidden(self, h):
// the encoder hidden is (layers*directions) x batch x dim
// we need to convert it to layers x batch x (directions*dim)
if self.encoder.num_directions == 2:
h = torch.cat([h[0:h.size(0):2], h[1:h.size(0):2]], 2)
return h
def forward(self, input):
src = input[0]
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances
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: 649322cc76a3127fd76d47e15b0923eeeb16b62c
Time: 2017-09-22
Author: jingxil@foxmail.com
File Name: onmt/modules/SRU.py
Class Name: SRU_Compute
Method Name: backward
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