meshgrid

paddle. meshgrid ( *args, **kwargs ) [source]

Takes a list of N tensors as input *args, each of which is 1-dimensional vector, and creates N-dimensional grids.

Parameters
  • *args (Tensor|list of Tensor) – tensors (tuple(list) of tensor): the shapes of input k tensors are (N1,), (N2,),…, (Nk,). Support data types: float64, bfloat16, float16, float32, int32, int64, complex64, complex128.

  • **kwargs (optional) – Currently, only accept name in **kwargs The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name.

Returns

k tensors. The shape of each tensor is (N1, N2, …, Nk)

Return type

Tensor

Examples

>>> import paddle

>>> x = paddle.randint(low=0, high=100, shape=[100])
>>> y = paddle.randint(low=0, high=100, shape=[200])

>>> grid_x, grid_y = paddle.meshgrid(x, y)

>>> print(grid_x.shape)
[100, 200]
>>> print(grid_y.shape)
[100, 200]