Questions tagged [torchmetrics]
9 questions
2
votes
0 answers
Using torchmetrics with nan values
I'm, working on a a DL project and using pytorch lightning and torchmetrics.
I'm using a metric that is just irrelevant for examples, which means that there exist batches for which this metric will get a NaN value.
The problem is the aggregated…

Nadav Schweiger
- 97
- 12
1
vote
0 answers
Torchmetrics Multiclass F1Score same results as Accuracy
I am trying to log several metrics over my unbalanced classification dataset using the MetricTracker of the torchmetrics library. I find that the results for Precision Recall and F1Score always equal to the Accuracy even though it should not.
A…

some_name.py
- 777
- 5
- 16
0
votes
0 answers
The compute method of metric Multiclass Accuracy was called before the update method
This is my code:
def _train_one_epoch(self, epoch: int) -> None:
self.model.train()
train_running_loss = 0.0
training_progress = 0
# len of all batches
total_batches = (
len(self.dataset_config.train_data) //…

Sadegh Pouriyan
- 157
- 1
- 10
0
votes
1 answer
F1Score from torchmetrics is not calculated correctly when using Average Meter pytorch
I am using AverageMeter to calculate and sum the f1 score but it doesn't calculate correctly after each epoch is finished (or after evaluation).
I used torchmetric to calculate the f1core.
from time import time
import torch
import tqdm
from utils…

Omid Erfanmanesh
- 547
- 1
- 7
- 29
0
votes
0 answers
How can I calculate Jaccard Index for a batch of images?
Context:
I have done a detection application. For each image, M mask detections are made. Each image has N ground truths elements. For each image M and N can be different.
A mask is of shape [widht,height]
I've grouped those images in batches of…
0
votes
0 answers
why is the dice function from torchvision not giving the correct result?
I am getting a different result from torchvisions dice function, than what I would expect. I am sure there is a very simple explanation for this, but I can't figure it out.
import torch
from torchmetrics.functional import dice
preds =…

jackson1234
- 21
- 2
0
votes
2 answers
Torchmetrics Frechet Inception Distance Weird Behaviour
I am trying to create an FID to measure the performance of my generative models on MNIST.
I provide my own feature extractor.
However, in order to find the output dimension of the feature extractor you provide, torchmetrics tries to pass it a dummy…

smartstix
- 21
- 2
0
votes
0 answers
pytorch lightning: validation with torchmetric extremely slow
I recently tried to implement a DeepLabV3 training pipeline using pytorch lightning. I wanted to use the build-in torchmetrics.JaccardIndex as my evaluation metric. My LightningModule looks like this:
import torchmetrics
from pytorch_lightning…

lukazso
- 1
- 2
0
votes
1 answer
TorchMetrics MultiClass accuracy for semantic segmentation
Let's use the following example for a semantic segmentation problem using TorchMetrics, where we predict tensors of shape (batch_size, classes, height, width):
# shape: (1, 3, 2, 2) => (batch_size, classes, height, width)
mask_multiclass_pred =…

daniel451
- 10,626
- 19
- 67
- 125