UpsamplingNearest2d#
- class torch.nn.UpsamplingNearest2d(size=None, scale_factor=None)[原始碼]#
對由多個輸入通道組成的輸入訊號應用 2D 最近鄰上取樣。
為了指定縮放比例,它接受
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.]]]])