其他分享
首页 > 其他分享> > torch.meshgrid(*tensors, **kwargs)函数的使用举例

torch.meshgrid(*tensors, **kwargs)函数的使用举例

作者:互联网

参考链接: torch.meshgrid(*tensors, **kwargs)
在这里插入图片描述
代码实验举例:

Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> x = torch.tensor([1, 2, 3])
>>> y = torch.tensor([4, 5, 6, 7, 8])
>>> x
tensor([1, 2, 3])
>>> y
tensor([4, 5, 6, 7, 8])
>>> grid_x, grid_y = torch.meshgrid(x, y)
>>> grid_x
tensor([[1, 1, 1, 1, 1],
        [2, 2, 2, 2, 2],
        [3, 3, 3, 3, 3]])
>>> grid_y
tensor([[4, 5, 6, 7, 8],
        [4, 5, 6, 7, 8],
        [4, 5, 6, 7, 8]])
>>>
>>>
>>>   

标签:tensor,torch,meshgrid,grid,kwargs,tensors
来源: https://blog.csdn.net/m0_46653437/article/details/111364615