Skip to content

ENH: Require that metrics for a model definition be a subclass of torchmetrics.Metric #707

@NickleDave

Description

@NickleDave

Right now a model definition requires that any metrics be Callable class.
See this line in vak.models.definition:

inspect.isclass(metrics_dict_val) and callable(metrics_dict_val)

This can lead to cryptic errors when implementing a model--see this discussion with @marisbasha on #699
#699 (comment)

I think we should instead require that any metrics be a subclass of torchmetrics.Metric. Basically, it should be a metric that's built into the library, or a custom metric that's implemented using the library (as described here).

This way we are explicit in the code, can give an explicit error about why it didn't work, and can help ensure we have consistent behavior for metrics.

The one thing to consider here is how to handle losses, that are often included as part of metrics so that one can get the loss on the validation set. E.g., we use the cross entropy loss class now for TweetyNet. Forcing people to write a metric subclass for every loss would be kind of annoying

Metadata

Metadata

Assignees

Labels

ENH: enhancementenhancement; new feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions