From b2d3b3c6772fb822c9ecc52ceab3130d9c00bfe5 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Wed, 27 Sep 2023 13:55:29 +0100 Subject: [PATCH] chore: related #21 --- views/py/python_model_template.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/views/py/python_model_template.py b/views/py/python_model_template.py index e782ecc..51fdbd4 100644 --- a/views/py/python_model_template.py +++ b/views/py/python_model_template.py @@ -32,7 +32,7 @@ model = keras.Sequential([ {{- if eq .LayerType 1}} layers.Rescaling(1./255), {{- else if eq .LayerType 2 }} - layers.Dense({{ .Shape }}, activation="relu"), + layers.Dense({{ .Shape }}, activation="sigmoid"), {{- else if eq .LayerType 3}} layers.Flatten(), {{- else }} @@ -41,7 +41,17 @@ model = keras.Sequential([ {{- end }} ]) -model.compile(loss=losses.SparseCategoricalCrossentropy(), optimizer=tf.keras.optimizers.Adam()) +model.compile( + loss=losses.SparseCategoricalCrossentropy(), + optimizer=tf.keras.optimizers.Adam(), + metrics=['accuracy']) -his = model.fit(dataset, validation_data= dataset_validation, epochs=100) +his = model.fit(dataset, validation_data= dataset_validation, epochs=50) +acc = his.history["accuracy"] + +f = open("accuracy.val", "w") +f.write(str(acc[-1])) +f.close() + +model.save("model.keras")