基础知识

上采样和PixelShuffle

2019-10-19  本文已影响0人  红豆汤来两大碗

转自:https://blog.csdn.net/g11d111/article/details/82855946

0、前言

1、Vision Layer

在PyTorch中,上采样的层被封装在torch.nn中的Vision Layers里面,一共有4种:
① PixelShuffle
② Upsample
③ UpsamplingNearest2d
④ UpsamplingBilinear2d

1.1 PixelShuffle

正常情况下,卷积操作会使feature map的高和宽变小。
但当我们的stride = 1/r < 1 时,可以让卷积后的feature map的高和宽变大——即分辨率增大,这个新的操作叫做sub-pixel convolution,具体原理可以看PixelShuffle《Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network 》的论文。

>>> ps = nn.PixelShuffle(3)
>>> input = torch.tensor(1, 9, 4, 4)
>>> output = ps(input)
>>> print(output.size())
torch.Size([1, 1, 12, 12])

2019年10月19日

上一篇 下一篇

猜你喜欢

热点阅读