1
Fork 0
mirror of https://github.com/Steffo99/unimore-bda-6.git synced 2024-11-25 17:24:20 +00:00

idk something more & more

This commit is contained in:
Steffo 2023-02-10 06:21:50 +01:00
parent 03c6123d85
commit 07be21e809
Signed by: steffo
GPG key ID: 2A24051445686895
3 changed files with 10 additions and 3 deletions

View file

@ -65,6 +65,10 @@ def main():
run_counter += 1 run_counter += 1
slog.debug("Run #%d", run_counter) slog.debug("Run #%d", run_counter)
if run_counter >= 100:
slog.fatal("Exceeded 100 runs, giving up and exiting...")
exit(2)
try: try:
slog.debug("Instantiating %s with %s...", SentimentAnalyzer.__name__, Tokenizer.__name__) slog.debug("Instantiating %s with %s...", SentimentAnalyzer.__name__, Tokenizer.__name__)
sa = SentimentAnalyzer(tokenizer=Tokenizer()) sa = SentimentAnalyzer(tokenizer=Tokenizer())

View file

@ -50,8 +50,11 @@ class BaseSentimentAnalyzer(metaclass=abc.ABCMeta):
for review in evaluation_dataset_func(): for review in evaluation_dataset_func():
resulting_category = self.use(review.text) resulting_category = self.use(review.text)
evaluated += 1 evaluated += 1
try:
correct += 1 if round(resulting_category) == round(review.category) else 0 correct += 1 if round(resulting_category) == round(review.category) else 0
score += 1 - (abs(resulting_category - review.category) / 4) score += 1 - (abs(resulting_category - review.category) / 4)
except ValueError:
log.warning("Model execution on %s resulted in a NaN value: %s", review, resulting_category)
return EvaluationResults(correct=correct, evaluated=evaluated, score=score) return EvaluationResults(correct=correct, evaluated=evaluated, score=score)

View file

@ -248,7 +248,7 @@ class TensorflowPolarSentimentAnalyzer(TensorflowSentimentAnalyzer):
log.debug("Compiling model: %s", model) log.debug("Compiling model: %s", model)
model.compile( model.compile(
optimizer=tensorflow.keras.optimizers.Adam(global_clipnorm=1.0), optimizer=tensorflow.keras.optimizers.Adadelta(global_clipnorm=1.0),
loss=tensorflow.keras.losses.MeanSquaredError(), loss=tensorflow.keras.losses.MeanSquaredError(),
metrics=[ metrics=[
tensorflow.keras.metrics.MeanAbsoluteError(), tensorflow.keras.metrics.MeanAbsoluteError(),