nn_upsample | R Documentation |
Upsamples a given multi-channel 1D (temporal), 2D (spatial) or 3D (volumetric) data. The input data is assumed to be of the form minibatch x channels x optional depth x optional height] x width. Hence, for spatial inputs, we expect a 4D Tensor and for volumetric inputs, we expect a 5D Tensor.
nn_upsample(
size = NULL,
scale_factor = NULL,
mode = "nearest",
align_corners = NULL
)
size |
(int or |
scale_factor |
(float or |
mode |
(str, optional): the upsampling algorithm: one of |
align_corners |
(bool, optional): if |
The algorithms available for upsampling are nearest neighbor and linear, bilinear, bicubic and trilinear for 3D, 4D and 5D input Tensor, respectively.
One can either give a scale_factor or the target output size to calculate the output size. (You cannot give both, as it is ambiguous)
if (torch_is_installed()) {
input <- torch_arange(start = 1, end = 4, dtype = torch_float())$view(c(1, 1, 2, 2))
nn_upsample(scale_factor = c(2), mode = "nearest")(input)
nn_upsample(scale_factor = c(2, 2), mode = "nearest")(input)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.