1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-25 01:04:19 +00:00

Normalize mean value of tensorflow models

This commit is contained in:
Steffo 2023-02-10 17:33:54 +01:00
parent 07be21e809
commit ade3a6bdc7
Signed by: steffo
GPG key ID: 2A24051445686895
2 changed files with 2 additions and 2 deletions

View file

@ -259,7 +259,7 @@ class TensorflowPolarSentimentAnalyzer(TensorflowSentimentAnalyzer):
return model return model
def _translate_prediction(self, a: numpy.array) -> Category: def _translate_prediction(self, a: numpy.array) -> Category:
return a[0, 0] * 5 return (a[0, 0] + 0.5) * 5
__all__ = ( __all__ = (

View file

@ -41,7 +41,7 @@ class Review:
return tensorflow.convert_to_tensor(self.text, dtype=tensorflow.string) return tensorflow.convert_to_tensor(self.text, dtype=tensorflow.string)
def to_tensor_normvalue(self) -> tensorflow.Tensor: 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]: def to_tensor_tuple_normvalue(self) -> tuple[tensorflow.Tensor, tensorflow.Tensor]:
return ( return (