Convolutional Decoder

class ezflow.decoder.conv_decoder.ConvDecoder(config=[128, 128, 96, 64, 32], concat_channels=None, to_flow=True, block=None)[source]

Applies a 2D Convolutional decoder to the input feature map. Used in PWCNet (https://arxiv.org/abs/1709.02371)

Parameters
  • config (List[int], default : [128, 128, 96, 64, 32]) – List containing all output channels of the decoder

  • concat_channels (int, optional) – Additional input channels to be concatenated for convolution layers

  • to_flow (bool, default : True) – If True, convoloves decoder output to optical flow of shape N x 2 x H x W

  • block (object, default : None) – the conv block to be used to build the decoder layers.

forward(x)[source]

Performs forward pass.

Parameters

x (torch.Tensor) – Input feature map

Returns

  • torch.Tensor – A tensor of shape N x 2 x H x W representing the flow

  • torch.Tensor – Tensor of shape N x output_channel x H x W

class ezflow.decoder.conv_decoder.FlowNetConvDecoder(in_channels=1024, config=[512, 256, 128, 64])[source]

Applies a 2D Convolutional decoder to regress the optical flow from the intermediate outputs convolutions of the encoder. Used in FlowNetSimple (https://arxiv.org/abs/1504.06852)

Parameters
  • in_channels (int, default: 1024) – Number of input channels of the decoder. This value should be equal to the final output channels of the encoder

  • config (List[int], default : [512, 256, 128, 64]) – List containing all output channels of the decoder

forward(x)[source]

Performs forward pass.

Parameters

x (List[torch.Tensor]) – List of all the outputs from each convolution layer of the encoder

Returns

List of all the flow predictions from each decoder layer

Return type

List[torch.Tensor],

ezflow.decoder.conv_decoder.conv(in_channels, out_channels, kernel_size=3, stride=1, padding=1, dilation=1)[source]

Block for a 2D Convolutional layer with Leaky ReLU activation

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

  • kernel_size (int, default : 3) – Size of the kernel

  • stride (int, default : 1) – Stride of the convolution

  • dilation (int, default : 1) – Spacing between kernel elements

Returns

block containing nn.Conv2d layer and leaky relu

Return type

torch.nn.Sequential

ezflow.decoder.conv_decoder.deconv(in_channels, out_channels)[source]

Block for a 2D Transpose Convolutional layer with Leaky ReLU activation

Parameters
  • in_channels (int) – Number of input channels

  • out_channels (int) – Number of output channels

Returns

block containing nn.ConvTranspose2d layer and leaky relu

Return type

torch.nn.Sequential