Skip to content

There should be metrics package #22439

Description

@kaszperro

🚀 Feature

Why not implement some common metrics, to evaluate models, with strong GPU acceleration.

Motivation

When I need to evaluate model accuracy (ex. measure r squared) I have to write it by hand, or use Numpy or other library (without GPU support). It'd be cleaner and simpler to have dedicated package with Pytonic API. It could also provide performance benefits because of low-level (c++) optimizations.

Pitch

I'd like to have some package ex: torch.metrics then I could do something like:

from torch.metrics import RSquaredMetric
metric = RSquaredMetric()
out = model(input)
r_squared = metric(out, reference)

Or I could do:

from torch.metrics import MSEMetric
metric = MSEMetric()
out = model(input)
mse = metric(out, reference)

Alternatives

For now, I can use some Tensors modifications or use Numpy:

ref_val = reference_batch[key].cpu().detach().numpy()
cor_matrix = np.corrcoef(val, ref_val, rowvar=False)
n = cor_matrix.shape[0] // 2
out_r2[key] = [cor_matrix[i][i + n] for i in range(n)]

If you agree, I'd like to contribute.

cc @ezyang @gchanan @zou3519 @albanD @mruberry

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA request for a proper, new feature.module: numpyRelated to numpy support, and also numpy compatibility of our operatorsquansight-nackHigh-prio issues that have been reviewed by Quansight and are judged to be not actionable.triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Fields

    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