cderinbogaz/inpredo

ValueError: Unknown metric function:val_acc or

moozgoos opened this issue · 1 comments

With Kreas 2.2.4 saving checkpoint in this form:

checkpoint = ModelCheckpoint(target_dir, monitor='val_acc', verbose=1, save_best_only=True, mode='max')

is not working. It's giving error:

Traceback (most recent call last):
  File "c:\Users\pjasz\source\repos\inpredo-master\src\train-binary.py", line 76, in <module>
    model.compile(loss='categorical_crossentropy',
  File "C:\Users\pjasz\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\training.py", line 451, in compile
    handle_metrics(output_metrics)
  File "C:\Users\pjasz\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\engine\training.py", line 408, in handle_metrics
    metric_fn = metrics_module.get(metric)
  File "C:\Users\pjasz\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\metrics.py", line 78, in get
    return deserialize(str(identifier))
  File "C:\Users\pjasz\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\metrics.py", line 67, in deserialize
    return deserialize_keras_object(config,
  File "C:\Users\pjasz\AppData\Local\Programs\Python\Python38\lib\site-packages\keras\utils\generic_utils.py", line 164, in deserialize_keras_object
    raise ValueError('Unknown ' + printable_module_name +
ValueError: Unknown metric function:val_acc

Shouldn't we use acc instead?

metric = 'acc'
model.compile(loss='categorical_crossentropy',
                      optimizer=optimizers.rmsprop(),
                      metrics=[metric])
checkpoint = ModelCheckpoint(filepath=target_dir + 'weights-improvement-{epoch:02d}-{acc:.2f}.hdf5', monitor=metric,
                    verbose=2, save_best_only=True, mode='max')

Hi @moozgoos feel free to create a pull request if you like. I haven't checked the project for a while but this can be caused by a dependency change.