Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: Unknown metric function:val_acc or #15

Open
moozgoos opened this issue Dec 5, 2020 · 1 comment
Open

ValueError: Unknown metric function:val_acc or #15

moozgoos opened this issue Dec 5, 2020 · 1 comment

Comments

@moozgoos
Copy link

moozgoos commented Dec 5, 2020

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')
@cderinbogaz
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants