python报错:1only batches of spatial targets supported (non-empty 3D tensors) but got targets of size


因为在使用Crossentropyloss作为损失函数时,output=net(input)的output应该是[batchsize, channel, height, weight],而label则是[batchsize, height, weight],label是单通道灰度图,而在BCELoss中,两者都是[batchsize, channel, height, weight]。

我报错是因为label本应该是一维的,我在保存的时候处理成了3维。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM