不同的批次尺寸给出不同的测试分数(Pytorch)
我正在尝试使用不同的批次大小来测试我的模型,并且我的批次大小不同。 我是初学者。我已经尝试解决这个问题很长时间了,但是找不到任何有效的解决方案。 代码在这里。谢谢!
I am trying to test my model with different batch sizes and I am getting different dice for different batch sizes.
I am a beginner. I have tried to fix this problem for a long time, but I can’t find any effective solution.
The code is here. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它与您对平均指标的计算有关,无论它们是图像的(案例批量尺寸= 1)平均值还是在Minibatch平均值。无论哪种方式,无论使用什么批次尺寸,您都必须保持平均值。一种直接的解决方案是修改您的添加评分方法:
It has something to do with your calculation of average metrics, whether they are image-wise (case batch size = 1) averages or minibatch-wise averages. Either way, you have to keep the averaging consistent no matter what batch size you use. One direct solution is to modify your add method of Scoring:
结果根据批处理大小而改变?
这通常与批处理层(例如批处理标准化层)有关。测试代码时,请务必检查您处于评估模式。在您的情况下,
net.eval()
应解决问题。Results changing depending on the batch size?
This is typically related to batch-wise layers such as batch normalization layers. Always check you are in eval mode when testing your code. In your case,
net.eval()
should fix the issue.