mindspore.mint.nn.Upsample

查看源文件
class mindspore.mint.nn.Upsample(input, size=None, scale_factor=None, mode='nearest', align_corners=None, recompute_scale_factor=None)[源代码]

按照给定的 sizescale_factor 根据 mode 设置的插值方式,对输入 input 进行插值。

更多参考详见 mindspore.mint.nn.functional.interpolate()

支持平台:

Ascend

样例:

>>> import mindspore as ms
>>> from mindspore import mint
>>> x = ms.Tensor([[[[1.0, 2.0, 3.0, 4.0], [5.0, 6.0, 7.0, 8.0]]]])
>>> upsample = mint.nn.Upsample(size=(5, 5))
>>> out = upsample(x)
>>> print(x.asnumpy())
[[[[1. 2. 3. 4.]
   [5. 6. 7. 8.]]]]
>>> print(out.asnumpy())
[[[[1. 1. 2. 3. 4.]
   [1. 1. 2. 3. 4.]
   [1. 1. 2. 3. 4.]
   [5. 5. 6. 7. 8.]
   [5. 5. 6. 7. 8.]]]]
>>> print(out.shape)
(1, 1, 5, 5)