bed0a0ae26451c9897cf1ee0f7302e42eba9b42c,transformer/Models.py,,get_attn_subsequent_mask,#Any#,31
Before Change
""" Get an attention mask to avoid using the subsequent info."""
assert seq.dim() == 2
attn_shape = (seq.size(0), seq.size(1), seq.size(1) )
subsequent_mask = np.triu(np.ones(attn_shape), k=1).astype("uint8")
subsequent_mask = torch.from_numpy(subsequent_mask)
if seq.is_cuda:
After Change
sz_b, len_s = seq.size()
subsequent_mask = torch.ones((len_s, len_s), device=seq.device, dtype=torch.uint8)
subsequent_mask = torch.triu(subsequent_mask, diagonal=1)
subsequent_mask = subsequent_mask.unsqueeze(0).expand(sz_b, len_s, len_s)
return subsequent_mask
class Encoder(nn.Module):
""" A encoder model with self attention mechanism. """
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 4
Instances Project Name: jadore801120/attention-is-all-you-need-pytorch
Commit Name: bed0a0ae26451c9897cf1ee0f7302e42eba9b42c
Time: 2018-08-23
Author: yhhuang@nlg.csie.ntu.edu.tw
File Name: transformer/Models.py
Class Name:
Method Name: get_attn_subsequent_mask
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: __init__
Project Name: r9y9/deepvoice3_pytorch
Commit Name: 96ecbdba66058274e2ceb9f58261daa4a45eb873
Time: 2019-12-21
Author: zryuichi@gmail.com
File Name: deepvoice3_pytorch/modules.py
Class Name:
Method Name: get_mask_from_lengths