UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argume

同一个代码,在俩个不同的服务器上跑,其中一个会诱发上述的警告,另外一个却不会,猜测应该是不同服务器上Pytorch版本不一致的问题。主要原因在于在你的文件中用到了torch.meshgrid函数,而该函数严格调用需要显示地传递“indexing”参数,比如我的代码如下:

import torch
x_range = torch.tensor([0, 1, 2, 3, 4])
y_range = torch.tensor([0, 2, 3])
y, x = torch.meshgrid(y_range, x_range)
m, n = torch.meshgrid(y_range, x_range, indexing='ij')

传入参数“indexing"即可。

参考来源:

[1] https://blog.csdn.net/weixin_51972142/article/details/130664816

[2] https://wenku.csdn.net/answer/68f4858d5ce2b5b9f0197546e766f0aa

你可能感兴趣的:(Pytorch,PyTorch)