UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument. (Triggered internally at C:\actions-runner\_work\pytorch\pytorch\builder\windows\pytorch\aten\src\ATen\native\TensorShape.cpp:3191.) return _VF.meshgrid(tensors, **kwargs) # type: ignore[attr-defined]什么意思,怎么改
时间: 2023-07-06 15:41:19 浏览: 354
这个UserWarning是由于使用了torch.meshgrid函数而产生的,它提示我们在将来版本中,需要传递一个名为indexing的参数。当前版本的torch.meshgrid函数的调用方式是:
```
torch.meshgrid(*tensors, **kwargs)
```
为了避免这个警告信息的出现,我们需要在调用torch.meshgrid函数时,显式地传递indexing参数,例如:
```
torch.meshgrid(*tensors, indexing='ij')
```
其中,indexing的值可以是'ij'或者'xy'。'ij'表示输出的网格矩阵的第一个维度对应输入张量的第一个维度,第二个维度对应输入张量的第二个维度,以此类推。'xy'则表示输出的网格矩阵的第一个维度对应输入张量的第二个维度,第二个维度对应输入张量的第一个维度,以此类推。
相关问题
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argument.
UserWarning: torch.meshgrid:在即将发布的版本中,需要传递索引参数。这个警告是因为在下一个版本中,torch.meshgrid函数将要求传递索引参数。解决方法是在函数调用时使用return _VF.meshgrid(tensors, **kwargs, indexing='ij')来指定索引参数,并且添加# type: ignore[attr-defined]来解除警告。
UserWarning: torch.meshgrid: in an upcoming release, it will be required to pass the indexing argume
UserWarning: torch.meshgrid: 在即将发布的版本中,将需要传递索引参数。这个警告是由于在调用torch.meshgrid函数时没有传递索引参数引发的。您可以通过修改代码中的一行来解决这个问题。在functional.py文件的第568行,将return _VF.meshgrid(tensors, **kwargs)改为return _VF.meshgrid(tensors, **kwargs,indexing='ij')。这样就会传递索引参数'ij'给torch.meshgrid函数,避免了警告的出现。