From 983b7a6d0785380161c47ccd5e6fd4e893e4bafa Mon Sep 17 00:00:00 2001 From: Anshuman Mishra Date: Thu, 17 Aug 2023 08:09:59 +0530 Subject: [PATCH] add convert_to_tensor for perplexity --- keras_nlp/metrics/perplexity.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keras_nlp/metrics/perplexity.py b/keras_nlp/metrics/perplexity.py index 481ef30a42..989d868e1c 100644 --- a/keras_nlp/metrics/perplexity.py +++ b/keras_nlp/metrics/perplexity.py @@ -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), )