Skip to content
fn

upsample_nearest

→Tensor
upsample_nearest(input: Tensor, size: _Size = None, scale_factor: _Scale = None)

Resample input by nearest neighbours (deprecated).

interpolate(input, size, scale_factor, mode='nearest'), which it calls; it warns on every call, as the reference's does.

Parameters

inputTensor
A batch of 1-, 2- or 3-D signals, (N, C, *spatial).
sizeint or tuple of int= None
The output's spatial extent; give this or scale_factor.
scale_factorfloat or tuple of float= None
How many times larger the output is along each spatial axis.

Returns

Tensor

input with every pixel repeated to fill the new extent.

Examples

>>> import warnings
>>> import lucid
>>> from lucid.nn.functional import upsample_nearest
>>> with warnings.catch_warnings():
...     warnings.simplefilter("ignore")
...     y = upsample_nearest(lucid.randn(1, 3, 4, 4), scale_factor=2)
>>> y.shape
(1, 3, 8, 8)

Used by 1