Skip to content

Rewrite metrics module with model subclassing #343

@hvgazula

Description

@hvgazula

What would you like changed/added and why?
Rewrite functions in metrics.py with model subclassing. See here. The drawback of the current approach is that metrics have to be kept track of when training models and that can not always be possible.

What would be the benefit?
Currently, loading a model from a previously stored checkpoint (warm_start) throws the following warning

WARNING:tensorflow:Unable to restore custom metric. Please ensure that the layer implements get_config and from_config when saving. In addition, please use the custom_objects arg when calling load_model().

Does the change make something easier to use?
This change will avoid situations where the user has to document the metric used and subsequently pass it again at load time. Model sub-classing (with @keras.saving.register_keras_serializable) will greatly simplify this process.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions