Commit aaa37f05 authored by Zhanghao Wu's avatar Zhanghao Wu Committed by Facebook Github Bot
Browse files

Add 'ppl' to tensorboard (#1212)

Summary:
Originally, the 'ppl' is calculated but returned as a string, which will not be printed to the tensorboard.
Pull Request resolved: https://github.com/pytorch/fairseq/pull/1212

Differential Revision: D18339553

Pulled By: myleott

fbshipit-source-id: 52e64d5d173bfd79836a72ee103cb25c8bb2a4c2
parent 4d21c157
...@@ -306,7 +306,7 @@ def log_softmax(x, dim, onnx_trace=False): ...@@ -306,7 +306,7 @@ def log_softmax(x, dim, onnx_trace=False):
def get_perplexity(loss): def get_perplexity(loss):
try: try:
return '{:.2f}'.format(math.pow(2, loss)) return float('{:.2f}'.format(math.pow(2, loss)))
except OverflowError: except OverflowError:
return float('inf') return float('inf')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment