meshgrid

paddle. meshgrid ( args: Sequence[paddle.Tensor], name: str | None = None, indexing: str | None = None ) list[paddle.Tensor] [source]
paddle. meshgrid ( *args: Tensor, name: str | None = None, indexing: str | None = None ) list[paddle.Tensor]

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 api_guide_Name.

  • indexing (Optional[str]) – the indexing mode, either “xy” or “ij”, defaults to “ij”.If “xy” is selected, the first dimension corresponds to the cardinality of the second input and the second dimension corresponds to the cardinality of the first input. If “ij” is selected, the dimensions are in the same order as the cardinality of the inputs.

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)
paddle.Size([100, 200])
>>> print(grid_y.shape)
paddle.Size([100, 200])