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.

System Message: WARNING/2 (/usr/local/lib/python3.8/site-packages/paddle/tensor/creation.py:docstring of paddle.tensor.creation.meshgrid, line 1); backlink

Inline emphasis start-string without end-string.

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, float32, int32, int64.

  • **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)
print(grid_y.shape)

#the shape of res_1 is (100, 200)
#the shape of res_2 is (100, 200)