SubPixelUpsample¶

class SubPixelUpsample(in_channels, out_channels, upscale_factor=2)[source]¶

Sub-pixel upsampling module using PixelShuffle.

This module performs upsampling using sub-pixel convolution (PixelShuffle) which is more efficient than transposed convolution and produces better results.

Parameters:
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • upscale_factor (int) – Factor to increase spatial resolution. Default: 2

Initialize SubPixelUpsample.

Parameters:
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • upscale_factor (int) – Factor to increase spatial resolution. Default is 2.

Methods

forward

Forward pass through sub-pixel upsampling.

Attributes

training

forward(x)[source]¶

Forward pass through sub-pixel upsampling.

Parameters:

x (torch.Tensor) – Input tensor of shape (B, C, H, W)

Returns:

Upsampled tensor of shape (B, out_channels, H*upscale_factor, W*upscale_factor)

Return type:

torch.Tensor