/usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__
Edit: /usr/local/lib64/python3.6/site-packages/torch/nn/modules/__pycache__/pixelshuffle.cpython-36.pyc (4398B)
3
ûEgõ
ã @ sH d dl mZ ddlmZ ddlmZ G dd„ deƒZG dd „ d eƒZd
S )é )ÚModuleé )Ú
functionalé )ÚTensorc sR e Zd ZU dZdgZeeddœ‡ fdd„Zeedœdd „Z e
d
œdd„Z‡ ZS )
ÚPixelShufflea
Rearranges elements in a tensor of shape :math:`(*, C \times r^2, H, W)`
to a tensor of shape :math:`(*, C, H \times r, W \times r)`, where r is an upscale factor.
This is useful for implementing efficient sub-pixel convolution
with a stride of :math:`1/r`.
See the paper:
`Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network`_
by Shi et. al (2016) for more details.
Args:
upscale_factor (int): factor to increase spatial resolution by
Shape:
- Input: :math:`(*, C_{in}, H_{in}, W_{in})`, where * is zero or more batch dimensions
- Output: :math:`(*, C_{out}, H_{out}, W_{out})`, where
.. math::
C_{out} = C_{in} \div \text{upscale\_factor}^2
.. math::
H_{out} = H_{in} \times \text{upscale\_factor}
.. math::
W_{out} = W_{in} \times \text{upscale\_factor}
Examples::
>>> pixel_shuffle = nn.PixelShuffle(3)
>>> input = torch.randn(1, 9, 4, 4)
>>> output = pixel_shuffle(input)
>>> print(output.size())
torch.Size([1, 1, 12, 12])
.. _Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network:
https://arxiv.org/abs/1609.05158
Úupscale_factorN)r Úreturnc s t t| ƒjƒ || _d S )N)Úsuperr Ú__init__r )Úselfr )Ú __class__© úI/usr/local/lib64/python3.6/site-packages/torch/nn/modules/pixelshuffle.pyr 0 s zPixelShuffle.__init__)Úinputr c C s t j|| jƒS )N)ÚFZ
pixel_shuffler )r r r r r Úforward4 s zPixelShuffle.forward)r c C s dj | jƒS )Nzupscale_factor={})Úformatr )r r r r Ú
extra_repr7 s zPixelShuffle.extra_repr)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
__constants__Úintr r r r Ústrr Ú
__classcell__r r )r
r r s
%r c sR e Zd ZU dZdgZeeddœ‡ fdd„Zeedœdd „Z e
d
œdd„Z‡ ZS )
ÚPixelUnshuffleaò Reverses the :class:`~torch.nn.PixelShuffle` operation by rearranging elements
in a tensor of shape :math:`(*, C, H \times r, W \times r)` to a tensor of shape
:math:`(*, C \times r^2, H, W)`, where r is a downscale factor.
See the paper:
`Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network`_
by Shi et. al (2016) for more details.
Args:
downscale_factor (int): factor to decrease spatial resolution by
Shape:
- Input: :math:`(*, C_{in}, H_{in}, W_{in})`, where * is zero or more batch dimensions
- Output: :math:`(*, C_{out}, H_{out}, W_{out})`, where
.. math::
C_{out} = C_{in} \times \text{downscale\_factor}^2
.. math::
H_{out} = H_{in} \div \text{downscale\_factor}
.. math::
W_{out} = W_{in} \div \text{downscale\_factor}
Examples::
>>> pixel_unshuffle = nn.PixelUnshuffle(3)
>>> input = torch.randn(1, 1, 12, 12)
>>> output = pixel_unshuffle(input)
>>> print(output.size())
torch.Size([1, 9, 4, 4])
.. _Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network:
https://arxiv.org/abs/1609.05158
Údownscale_factorN)r r c s t t| ƒjƒ || _d S )N)r
r r r )r r )r
r r r b s zPixelUnshuffle.__init__)r r c C s t j|| jƒS )N)r Zpixel_unshuffler )r r r r r r f s zPixelUnshuffle.forward)r c C s dj | jƒS )Nzdownscale_factor={})r r )r r r r r i s zPixelUnshuffle.extra_repr)
r r r r r r r r r r r r r r r )r
r r ; s
#r N) Úmoduler Ú r r Ztorchr r r r r r r Ú
s 4