pytorch使用过程中遇到的警告

1、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.item()   

2、TypeError: backward() got an unexpected keyword argument ‘retain_variables’
解决办法:
版本问题

3、UserWarning: The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.

4、Using a target size (torch.Size([128])) that is different to the input size (torch.Size([128, 1])) is deprecated. Please ensure they have the same size.
“Please ensure they have the same size.”.format(target.size(), input.size()))

你可能感兴趣的:(pytorch使用过程中遇到的警告)