标签:clu data Dimension python dimens cuda tor was pytho
1.
UserWarning: Implicit dimension choice for log_softmax has been deprecated. Change the call to include dim=X as an argument.
return F.log_softmax(x)
解决方法:把 F.log_softmax(x)改为F.log_softmax(x,dim=0) , 而且我发现改为F.log_softmax(x,dim=1),这个到底哪个更合理需要进一步确认。
2.
UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number train_loss += loss.data[0]
解决方法:把 train_loss+=loss.data[0] 修改为 train_loss+= loss.item()
3.
UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead. label = Variable(label.cuda(), volatile=True)
解决方法:把 label = Variable(label.cuda(), volatile=True) 修改为 label = Variable(label.cuda())
记录下pytorch代码从0.3版本迁移到0.4版本要做的一些更改。
标签:clu data Dimension python dimens cuda tor was pytho
原文地址:https://www.cnblogs.com/www-caiyin-com/p/9953833.html