torch.meshgrid 和 numpy.meshgrid的区别
torch.meshgrid 和 numpy.meshgrid的输出方向不同。
###输入
import torch
import numpy as np
x = torch.arange(3)
y = torch.arange(10,14)
print(torch.meshgrid([x,y]))
print(np.meshgrid(x.numpy(), y.numpy()))
###torch.meshgrid()输出
x=tensor([[0, 0, 0, 0],
[1, 1, 1, 1],
[2, 2, 2, 2]]),
y=tensor([[10, 11, 12, 13],
[10, 11, 12, 13],
[10, 11, 12, 13]])
###numpy.meshgrid()输出
[array([[0, 1, 2],
[0, 1, 2],
[0, 1, 2],
[0, 1, 2]]),
array([[10, 10, 10],
[11, 11, 11],
[12, 12, 12],
[13, 13, 13]])]