admin管理员组文章数量:1287523
I am new to pytorch
and torchvision
.
Apparently, the __call__
method of a model returns different things if they are on train mode or not. The first case returns the loss, the second returns the outputs.
This is quite bothersome for two reasons:
- I need to do very strange things to compute the validation loss to plot the history as one will do with TF,
- either I have a big error if I have layers like dropout or batch norm
- or using a function of 100 lines of code.
source: .
- Also, if I want to use
torchmetrics
with the train data, I need to change to eval and send again thetrain_dataloader
. Seems like a waste of computation time.
Is this indeed the case? Otherwise, how can I do this two things using best practices? My code looks quite messy with all this.
I am new to pytorch
and torchvision
.
Apparently, the __call__
method of a model returns different things if they are on train mode or not. The first case returns the loss, the second returns the outputs.
This is quite bothersome for two reasons:
- I need to do very strange things to compute the validation loss to plot the history as one will do with TF,
- either I have a big error if I have layers like dropout or batch norm
- or using a function of 100 lines of code.
source: https://stackoverflow/a/71315672/5931672.
- Also, if I want to use
torchmetrics
with the train data, I need to change to eval and send again thetrain_dataloader
. Seems like a waste of computation time.
Is this indeed the case? Otherwise, how can I do this two things using best practices? My code looks quite messy with all this.
Share Improve this question asked Feb 24 at 10:17 J Agustin BarrachinaJ Agustin Barrachina 4,1003 gold badges42 silver badges67 bronze badges 1- What version of torchvision are you using? Looking at the code for rcnn for example it seems to return losses so long as targets are passed – Karl Commented Feb 24 at 19:23
1 Answer
Reset to default 0Ok, apparently I'm not the only one to think this is not good, and many others had the same issue:
- Add an option for Dection Models to return cost in eval mode as well (validation, test loss) · Issue #1574
- [models] Suggestion of GeneralizedRCNN forward output · Issue #1775
- Calculate Training Accuracy on resnet152 · Issue #2578
本文标签: pytorchtrain and validation metrics and loss using torchvisionStack Overflow
版权声明:本文标题:pytorch - train and validation metrics and loss using torchvision - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741278314a2369862.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论