UpsamplingNearest2d¶
- class torch.nn.UpsamplingNearest2d(size=None, scale_factor=None)[source][source]¶
對由多個輸入通道組成的輸入訊號應用二維最近鄰上取樣。
為了指定比例,它接受
size或scale_factor作為其建構函式引數。當給出
size時,它是影像的輸出尺寸 (h, w)。- 引數
警告
此類已被棄用,請改用
interpolate()。- 形狀
輸入: ,其中
輸出: ,其中
示例
>>> input = torch.arange(1, 5, dtype=torch.float32).view(1, 1, 2, 2) >>> input tensor([[[[1., 2.], [3., 4.]]]]) >>> m = nn.UpsamplingNearest2d(scale_factor=2) >>> m(input) tensor([[[[1., 1., 2., 2.], [1., 1., 2., 2.], [3., 3., 4., 4.], [3., 3., 4., 4.]]]])