b5486aaea994960688152e91fbab7699dc04e8c1,onmt/modules/GlobalAttention.py,GlobalAttention,score,#GlobalAttention#Any#Any#,69

Before Change


            // batch x src_len x dim
            uh = self.linear_context(h_s.contiguous())
            // batch x src_len x dim
            wquh = uh + wq.expand_as(uh)
            // batch x src_len x dim
            wquh = self.tanh(wquh)
            // batch x src_len
            return self.v(wquh.contiguous()).squeeze(2)

After Change



        if self.attn_type in ["general", "dot"]:
            if self.attn_type == "general":
                h_t_ = h_t.view(tgt_batch*tgt_len, tgt_dim)
                h_t_ = self.linear_in(h_t_)
                h_t = h_t_.view(tgt_batch, tgt_len, tgt_dim)
            h_s_ = h_s.transpose(1, 2)
            // (batch, t_len, d) x (batch, d, s_len) --> (batch, t_len, s_len)
            return torch.bmm(h_t, h_s_)
        else:
            wq = self.linear_query(h_t.view(-1, dim))
            wq = wq.view(tgt_batch, tgt_len, 1, dim)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: OpenNMT/OpenNMT-py
Commit Name: b5486aaea994960688152e91fbab7699dc04e8c1
Time: 2017-08-14
Author: taolei@csail.mit.edu
File Name: onmt/modules/GlobalAttention.py
Class Name: GlobalAttention
Method Name: score


Project Name: cornellius-gp/gpytorch
Commit Name: b2951813547426828d313a80c52de8a619e99731
Time: 2018-11-26
Author: gpleiss@gmail.com
File Name: gpytorch/lazy/constant_mul_lazy_tensor.py
Class Name: ConstantMulLazyTensor
Method Name: _quad_form_derivative


Project Name: cornellius-gp/gpytorch
Commit Name: 1972461c3c06d11872cdf62941a616ee82c858a8
Time: 2018-08-17
Author: gpleiss@gmail.com
File Name: gpytorch/lazy/constant_mul_lazy_variable.py
Class Name: ConstantMulLazyVariable
Method Name: _constant_as