3) logging outputs to display while training
net_output = model(**sample["net_input"])
input = F.log_softmax(net_output.view(-1, net_output.size(-1)), dim=1)
target = sample["target"].view(-1)
loss = LabelSmoothedNLLLoss.apply(input, target, self.eps, self.padding_idx, self.weights, reduce)
sample_size = sample["target"].size(0) if self.args.sentence_avg else sample["ntokens"]
logging_output = {
After Change
2) the sample size, which is used as the denominator for the gradient
3) logging outputs to display while training
net_output = model(**sample["net_input"])
lprobs = model.get_normalized_probs(net_output, log_probs=True)
target = sample["target"].view(-1)
loss = LabelSmoothedNLLLoss.apply(lprobs, target, self.eps, self.padding_idx, self.weights, reduce)
sample_size = sample["target"].size(0) if self.args.sentence_avg else sample["ntokens"]
logging_output = {