Skip to content

Instantly share code, notes, and snippets.

@Gregorgeous
Gregorgeous / README.md
Created June 10, 2019 12:21
TF 2.0 Perplexity Metric: custom TF 2.0 Metric class measuring model's perplexity for language generation networks.

Custom TF2.0 Perplexity Metric

  • In TensorFlow 2.0 metrics have a brand new form of "stateful" objects that have a uniform API consisting of 4 methods:
def __init__(self):
  #...
def update_state(self, y_true, y_pred, sample_weight=None):
  #...
def result(self):
  #...
def reset_states(self):