torch_meshgrid: Meshgrid

View source: R/gen-namespace.R

torch_meshgridR Documentation

Meshgrid

Description

Take N tensors, each of which can be either scalar or 1-dimensional vector, and create N N-dimensional grids, where the i th grid is defined by expanding the i th input over dimensions defined by other inputs.

Usage

torch_meshgrid(tensors, indexing)

Arguments

tensors

(list of Tensor) list of scalars or 1 dimensional tensors. Scalars will be treated (1,).

indexing

(str, optional): the indexing mode, either “xy” or “ij”, defaults to “ij”. See warning for future changes. 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.

Warning

In the future torch_meshgrid will transition to indexing=’xy’ as the default. This issue tracks this issue with the goal of migrating to NumPy’s behavior.

Examples

if (torch_is_installed()) {

x = torch_tensor(c(1, 2, 3))
y = torch_tensor(c(4, 5, 6))
out = torch_meshgrid(list(x, y))
out
}

torch documentation built on May 29, 2024, 9:54 a.m.