saroalre
saroalre

Reputation: 1

With keras 3.2.1 and tensorflow 2.16.1 the output of calling "model.metrics" is ['loss', 'compile_metrics'] after loading a model with keras tuner

A search for the best parameters for a model (namely U-Net) for multiclassification was performed and when compiling the model within the so-called 'model_builder' function two metrics were included: categorical accuracy and f1. However when reloading the models after the search using keras tuner the output of using model.metrics or model.evaluate is: ['loss', 'compile_metrics']. It shows neither accuracy nor f1.

Does anyone know what it could be?

---Piece of code---

Model builder:

METRICS = [ keras.metrics.CategoricalAccuracy(name='accuracy'), f1_weighted ]

 # Tune the learning rate for the optimizer
# Choose an optimal value from 0.01, 0.001, or 0.0001
hp_learning_rate = hp.Choice('learning_rate', values=[1e-2, 1e-3])

optimizer = keras.optimizers.Adam(learning_rate=hp_learning_rate)
loss = tf.keras.losses.CategoricalFocalCrossentropy()

model.compile(loss=loss,
              optimizer=optimizer,
              metrics=METRICS,
              jit_compile=False)
  
return model

Output:

model = model_builder(best_hps[0])

model.metrics_names

Upvotes: 0

Views: 97

Answers (0)

Related Questions