Vision: Calculate Training Accuracy on resnet152

Created on 12 Aug 2020  路  6Comments  路  Source: pytorch/vision

I'm trying to calculate training accuracy on resnet152, however
loss_dict = model(images, targets)
only contains loss values.

Usually the model accepts only the images and the outputs are then passed to a loss function as well as used to calculate the accuracy. Calling it without the targets parameter results in:
ValueError: In training mode, targets should be passed

Sorry if this is the wrong place, I'm still quite a beginner.

invalid models question

All 6 comments

Hi @FrostByteGER

this is an issue tracker and not a help form. Our primary means of support is our discussion forum. As such I'm closing this issue.


Usually the model accepts only the images and the outputs are then passed to a loss function as well as used to calculate the accuracy.

That is correct:

https://github.com/pytorch/vision/blob/c547e5cbbf25e46870abb2e925b42c67c3367afc/torchvision/models/resnet.py#L219

Thus loss_dict = model(images, targets) is not a valid call if model is a ResNet variant from torchvision. Furthermore the ValueError is not raised by us.

Together that implies you are using something else besides vanilla torchvision. You might want to include more details in future question so other have a better chance to help you.

I believe @FrostByteGER was using one of the detection models.

For optimization purposes, we currently don't return the predictions of the model during training time. This is something that could be extended in the future, but would incur a slowdown in the training time.

I believe @FrostByteGER was using one of the detection models.

For optimization purposes, we currently don't return the predictions of the model during training time. This is something that could be extended in the future, but would incur a slowdown in the training time.

Indeed. I used the following: https://pytorch.org/docs/stable/torchvision/models.html#faster-r-cnn with an Resnet 152 model.

I suggest a switch in the constructor to toggle predictions as a return value with a default of False for backward compatibility.
This would help a lot to get more metrics out of the training!

Yes, this has been discussed in the past in https://github.com/pytorch/vision/issues/1775

Let's keep the discussion there (I've just found that I've missed replying to it...)

Sorry for missing this obvious detail. @FrostByteGER next time include that into your issue description or tell me if I guess wrong. I probably could have provided better support.

Sorry for missing this obvious detail. @FrostByteGER next time include that into your issue description or tell me if I guess wrong. I probably could have provided better support.

Yeah I was frustrated and tired and actually failed to include that, sorry for that!

Was this page helpful?
0 / 5 - 0 ratings