Skip to content

Commit

Permalink
add convert_to_tensor for perplexity
Browse files Browse the repository at this point in the history
  • Loading branch information
shivance committed Aug 17, 2023
1 parent e4531ad commit 983b7a6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion keras_nlp/metrics/perplexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def update_state(self, y_true, y_pred, sample_weight=None):

def result(self):
perplexity_score = ops.where(
ops.equal(self._number_of_samples, 0),
ops.equal(ops.convert_to_tensor(self._number_of_samples), 0),
0,
ops.exp(self._aggregate_crossentropy / self._number_of_samples),
)
Expand Down

0 comments on commit 983b7a6

Please sign in to comment.