From ade3a6bdc72cdb4385cce500bece6d5571da08c4 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 10 Feb 2023 17:33:54 +0100 Subject: [PATCH] Normalize mean value of tensorflow models --- unimore_bda_6/analysis/tf_text.py | 2 +- unimore_bda_6/database/datatypes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unimore_bda_6/analysis/tf_text.py b/unimore_bda_6/analysis/tf_text.py index 351396c..e8e8fa9 100644 --- a/unimore_bda_6/analysis/tf_text.py +++ b/unimore_bda_6/analysis/tf_text.py @@ -259,7 +259,7 @@ class TensorflowPolarSentimentAnalyzer(TensorflowSentimentAnalyzer): return model def _translate_prediction(self, a: numpy.array) -> Category: - return a[0, 0] * 5 + return (a[0, 0] + 0.5) * 5 __all__ = ( diff --git a/unimore_bda_6/database/datatypes.py b/unimore_bda_6/database/datatypes.py index 1273f72..f5517f1 100644 --- a/unimore_bda_6/database/datatypes.py +++ b/unimore_bda_6/database/datatypes.py @@ -41,7 +41,7 @@ class Review: return tensorflow.convert_to_tensor(self.text, dtype=tensorflow.string) def to_tensor_normvalue(self) -> tensorflow.Tensor: - return tensorflow.convert_to_tensor([self.category / 5], dtype=tensorflow.float32) + return tensorflow.convert_to_tensor([self.category / 5 - 0.5], dtype=tensorflow.float32) def to_tensor_tuple_normvalue(self) -> tuple[tensorflow.Tensor, tensorflow.Tensor]: return (