ce69ccc9be6560ca1ccf82319a0af2bebde1ceda,onmt/utils/loss.py,NMTLossCompute,__init__,#NMTLossCompute#Any#Any#Any#Any#,180
Before Change
one_hot = torch.randn(1, len(tgt_vocab))
one_hot.fill_(label_smoothing / (len(tgt_vocab) - 2))
one_hot[0][self.padding_idx] = 0
self.register_buffer("one_hot", one_hot)
else:
weight = torch.ones(len(tgt_vocab))
weight[self.padding_idx] = 0
self.criterion = nn.NLLLoss(weight, size_average=False)
After Change
def __init__(self, generator, tgt_vocab, normalization="sents",
label_smoothing=0.0):
super(NMTLossCompute, self).__init__(generator, tgt_vocab)
self.sparse = not isinstance(generator[1], nn.LogSoftmax)
if label_smoothing > 0:
self.criterion = LabelSmoothingLoss(
label_smoothing, len(tgt_vocab), ignore_index=self.padding_idx
In pattern: SUPERPATTERN
Frequency: 5
Non-data size: 2
Instances
Project Name: OpenNMT/OpenNMT-py
Commit Name: ce69ccc9be6560ca1ccf82319a0af2bebde1ceda
Time: 2018-08-25
Author: benzurdopeters@gmail.com
File Name: onmt/utils/loss.py
Class Name: NMTLossCompute
Method Name: __init__
Project Name: rusty1s/pytorch_geometric
Commit Name: d08f673481a2cfaa0ce702e80cc22cdd25e600e5
Time: 2020-05-31
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/nn/models/schnet.py
Class Name: GaussianSmearing
Method Name: __init__
Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: a049ecb81701dd61744cbbf5922c4dc2ee6542fa
Time: 2017-10-28
Author: max.lapan@gmail.com
File Name: ch07/lib/dqn_model.py
Class Name: NoisyFactorizedLinear
Method Name: __init__
Project Name: rusty1s/pytorch_geometric
Commit Name: 6ad34e5887f847aeb9f681e8f290d5877b76e52b
Time: 2020-05-13
Author: matthias.fey@tu-dortmund.de
File Name: torch_geometric/nn/models/schnet.py
Class Name: GaussianSmearing
Method Name: __init__
Project Name: pytorch/fairseq
Commit Name: b8a938e96e08e5b39deb585d6cc6690de062dd4d
Time: 2020-10-22
Author: myleott@fb.com
File Name: fairseq/models/bart/hub_interface.py
Class Name: BARTHubInterface
Method Name: __init__