解决:UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars;
UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars;will instead unsqueeze and return a vector.
·
Warning
model在多卡DataParallel调用时在loss的地方会出现:
UserWarning: Was asked to gather along dimension 0, but all input tensors were scalars;will instead unsqueeze and return a vector.
每次看到都很烦,虽然不影响运行
我的问题
在model里计算loss时写了loss.mean(),trainer里也写了loss.mean()
解决
删去model 里的 loss.mean(),或者其他对多卡loss汇聚的操作,只留下trainer中loss.mean()
更多推荐
所有评论(0)