// in cross_entropy:
// github.com/pytorch/fairseq/blob/master/fairseq/criterions/cross_entropy.py//L55
if "train_loss" in m:
m["train_ppl"] = np.exp2(m["train_loss"])
if "valid_loss" in m:
m["ppl"] = np.exp2(m["valid_loss"])
After Change
if "nll_loss" in self.meters:
// special case, we used sentence averaging so ppl comes from nll_loss
output["ppl"] = np.exp2(self.meters["nll_loss"].avg)
else:
// normal case, just use loss
output["ppl"] = np.exp2(self.meters["loss"].avg)