torch.meshgrid
-
torch.meshgrid(*tensors)
[source] -
Take tensors, each of which can be either scalar or 1-dimensional vector, and create N-dimensional grids, where the th grid is defined by expanding the th input over dimensions defined by other inputs.
- Parameters
-
tensors (list of Tensor) – list of scalars or 1 dimensional tensors. Scalars will be treated as tensors of size automatically
- Returns
-
If the input has tensors of size , then the output would also have tensors, where all tensors are of size .
- Return type
-
seq (sequence of Tensors)
Example:
>>> x = torch.tensor([1, 2, 3]) >>> y = torch.tensor([4, 5, 6]) >>> grid_x, grid_y = torch.meshgrid(x, y) >>> grid_x tensor([[1, 1, 1], [2, 2, 2], [3, 3, 3]]) >>> grid_y tensor([[4, 5, 6], [4, 5, 6], [4, 5, 6]])
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.meshgrid.html