• Stars
    star
    108
  • Rank 319,441 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Metrics for model evaluation in pytorch

Torch-metrics

PyPI version License: MIT

Model evaluation metrics for PyTorch

Torch-metrics serves as a custom library to provide common ML evaluation metrics in Pytorch, similar to tf.keras.metrics.

As summarized in this issue, Pytorch does not have a built-in libary torch.metrics for model evaluation metrics. This is similar to the metrics library in PyTorch Lightning.

Usage

  • pip install --upgrade torch-metrics
from torch_metrics import Accuracy

## define metric ##
metric = Accuracy(from_logits=False)
y_pred = torch.tensor([1, 2, 3, 4])
y_true = torch.tensor([0, 2, 3, 4])

print(metric(y_pred, y_true))
## define metric ##
metric = Accuracy()
y_pred = torch.tensor([[0.2, 0.6, 0.1, 0.05, 0.05],
                       [0.2, 0.1, 0.6, 0.05, 0.05],
                       [0.2, 0.05, 0.1, 0.6, 0.05],
                       [0.2, 0.05, 0.05, 0.05, 0.65]])
y_true = torch.tensor([0, 2, 3, 4])

print(metric(y_pred, y_true))

Implementation

Metrics from tf.keras.metrics and other metrics that are already implemented vs to-do

  • MeanSquaredError class
  • RootMeanSquaredError class
  • MeanAbsoluteError class
  • Precision class
  • Recall class
  • MeanIoU class
  • DSC class (Dice Similarity Coefficient)
  • F1Score class
  • RSquared class
  • Hinge class
  • SquaredHinge class
  • LogCoshError class
  • Accuracy class
  • KLDivergence class
  • CosineSimilarity class
  • AUC class
  • BinaryCrossEntropy class
  • CategoricalCrossEntropy class
  • SparseCategoricalCrossentropy class

Local Development and Testing

To quickly get started with local development, run:

make develop

To test, run:

python3 -m pytest

Pre-commit hooks

To run pre-commit against all files:

pre-commit run --all-files

Contributing

Please raise issues or feature requests here. It will be extremely helpful if you comment on a specific issue before working on it. This provides visibility for others who also intend to work on the same issue. Reference any pull requests to their original issues.

More Repositories

1

awesome-gans-and-deepfakes

A curated list of GAN & Deepfake papers and repositories.
314
star
2

plexiglass

A PyTorch toolbox for adversarial attack and deepfake detection research.
Python
58
star
3

vox2vox

3D volume-to-volume generative adversarial network for medical image segmentation
Python
52
star
4

awesome-ml-stack

A curated list of up-to-date company blogs and media on their machine learning stacks.
40
star
5

kalmanpy

Implementation of Kalman Filter in Python
Python
33
star
6

3dgan-keras

Keras implementation of 3dgan
Python
19
star
7

miptools

Medical image processing toolbox for quick preprocessing of CTs and MRIs
Python
17
star
8

building-from-scratch

building complicated stuff from scratch cuz why not ¯\_(ツ)_/¯
Jupyter Notebook
5
star
9

age-acgan-pytorch

Age-Conditioned Synthesis of Pediatric Computed Tomography with Auxiliary Classifier Generative Adversarial Networks
Python
4
star
10

ddqn-breakout

Agent trained on dueling Deep Q Network to play OpenAI Breakout-v0 and deterministic-v4
Python
4
star
11

property-visualization

Visualization of Hong Kong's property prices using Pandas, OverPy and Folium
HTML
3
star
12

protencoder

Python utility to implement various encoding methods for protein structures
Python
3
star
13

fast-CDRScan

Pytorch implementation of Deep Cancer Drug Response Profile scan with EfficientNets
Python
1
star
14

covid19-stats

Python wrapper functions for retrieving real-time and past information from JHU CSSE database
Python
1
star
15

bs-dcgan

BatchNorm- SELU Deep Convolutional Generative Adversarial Network implemented in Tensorflow
JavaScript
1
star
16

Rubiks

data structure to represent an n times n Rubiks cube for solvers
1
star