【Pytorch】ValueError: Expected more than 1 value per channel when training,got input size...

淡淡的烟草味﹌ 2022-10-23 08:24 241阅读 0赞

ValueError: Expected more than 1 value per channel when training,got input size…

在 BatchNorm 的forward地方报错

  1. ValueError: Expected more than 1 value per channel when traininggot input size...

如果输入是[N,X,1]需要[N,X,1+]

流行解释:训练中用batch训练的时候当前batch恰好只含一个sample,而由于BatchNorm操作需要多于一个数据计算平均值
普遍解决方法: dataLoader(drop_last=True)

但是没用,不能改变网络结构,因为在train 的时候没问题
检查看到 test 的时候加载的数据是:

  1. test_seq_input = motion[0, :1, :]

改成

  1. test_seq_input = motion[0, :2, :]

不报这个问题了

发表评论

表情:
评论列表 (有 0 条评论,241人围观)

还没有评论,来说两句吧...

相关阅读