UpsamplingNearest2d¶
- class torch.nn.UpsamplingNearest2d(size=None, scale_factor=None)[source][source]¶
將 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.]]]])