vis4d.op.layer.conv2d

Wrapper for conv2d.

Functions

add_conv_branch(num_branch_convs, ...)

Init conv branch for head.

Classes

Conv2d(*args[, norm, activation])

Wrapper around Conv2d to support empty inputs and norm/activation.

UnetDownConv(in_channels, out_channels[, ...])

Downsamples a feature map by applying two convolutions and maxpool.

UnetDownConvOut(features, pooled_features)

Output of the UnetDownConv operator.

UnetUpConv(in_channels, out_channels[, ...])

An operator that performs 2 convolutions and 1 UpConvolution.

class Conv2d(*args, norm=None, activation=None, **kwargs)[source]

Wrapper around Conv2d to support empty inputs and norm/activation.

Creates an instance of the class.

If norm is specified, it is initialized with 1.0 and bias with 0.0.

forward(x)[source]

Forward pass.

Return type:

Tensor

class UnetDownConv(in_channels, out_channels, pooling=True, activation='ReLU')[source]

Downsamples a feature map by applying two convolutions and maxpool.

Creates a new downsampling convolution operator.

This operator consists of two convolutions followed by a maxpool operator.

Parameters:
  • in_channels (int) – input channesl

  • out_channels (int) – output channesl

  • pooling (bool) – If pooling should be applied

  • activation (str) – Activation that should be applied

__call__(data)[source]

Applies the operator.

Parameters:

data (Tensor) – Input data.

Returns:

Containing the features before the pooling

operation (features) and after (pooled_features).

Return type:

UnetDownConvOut

forward(data)[source]

Applies the operator.

Parameters:

data (Tensor) – Input data.

Returns:

containing the features before the pooling

operation (features) and after (pooled_features).

Return type:

UnetDownConvOut

class UnetDownConvOut(features: Tensor, pooled_features: Tensor)[source]

Output of the UnetDownConv operator.

features: Features before applying the pooling operator pooled_features: Features after applying the pooling operator

Create new instance of UnetDownConvOut(features, pooled_features)

features: Tensor

Alias for field number 0

pooled_features: Tensor

Alias for field number 1

class UnetUpConv(in_channels, out_channels, merge_mode='concat', up_mode='transpose')[source]

An operator that performs 2 convolutions and 1 UpConvolution.

A ReLU activation follows each convolution.

Creates a new UpConv operator.

This operator merges two inputs by upsampling one and combining it with the other.

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

  • out_channels (int) – Number of output channels (high res)

  • merge_mode (str) – How to merge both input channels

  • up_mode (str) – How to upsample the channel with lower resolution

Raises:

ValueError – If upsampling mode is unknown

__call__(from_down, from_up)[source]

Forward pass.

Parameters:
  • from_down (Tensor) – Tensor from the encoder pathway. Assumed to have dimension ‘out_channels’

  • from_up (Tensor) – Upconv’d tensor from the decoder pathway. Assumed to have dimension ‘in_channels’

Return type:

Tensor

forward(from_down, from_up)[source]

Forward pass.

Parameters:
  • from_down (Tensor) – Tensor from the encoder pathway. Assumed to have dimension ‘out_channels’

  • from_up (Tensor) – Upconv’d tensor from the decoder pathway. Assumed to have dimension ‘in_channels’

Return type:

Tensor

add_conv_branch(num_branch_convs, last_layer_dim, conv_out_dim, conv_has_bias, norm_cfg, num_groups)[source]

Init conv branch for head.

Return type:

tuple[ModuleList, int]