nn.grid_sample
Given an input X and a flow-field grid, computes the output Y using X values and pixel locations from the grid.
Args
X
(@Tensor<T>
) - Input tensor of shape (N, C, D1, D2, ..., Dr), where N is the batch size, C is the number of channels, D1, D2, ..., Dr are the spatial dimensions.grid
(@Tensor<T>
) - Input offset of shape (N, D1_out, D2_out, ..., Dr_out, r), where D1_out, D2_out, ..., Dr_out are the spatial dimensions of the grid and output, and r is the number of spatial dimensions. Grid specifies the sampling locations normalized by the input spatial dimensions.align_corners
(Option<usize>
) - default is 0. If align_corners=1, the extrema are considered as referring to the center points of the input's corner pixels. If align_corners=0, they are instead considered as referring to the corner points of the input's corner pixelsmode
(Option<MODE>
) - default is linear. Three interpolation modes: linear (default), nearest and cubic.padding_mode
(Option<PADDING_MODE>
) - default is zeros. Support padding modes for outside grid values:zeros
(default),border
,reflection
.
Returns
A Tensor<T>
of shape (N, C, D1_out, D2_out, ..., Dr_out) of the sampled values.
Example
Last updated