vis4d.op.layer.mlp

MLP Layers.

Classes

ResnetBlockFC(size_in[, size_out, size_h])

Fully connected ResNet Block consisting of two linear layers.

TransformerBlockMLP(in_features[, ...])

MLP as used in Vision Transformer, MLP-Mixer and related networks.

class ResnetBlockFC(size_in, size_out=None, size_h=None)[source]

Fully connected ResNet Block consisting of two linear layers.

Fully connected ResNet Block consisting of two linear layers.

Parameters:
  • size_in (int) – (int) input dimension

  • size_out (Optional[int]) – Optional(int) output dimension, if not specified same as input

  • size_h (Optional[int]) – Optional(int) hidden dimension, if not specfied same as min(in,out)

__call__(data)[source]

Applies the layer.

Parameters:

data (Tensor) – (tensor) input shape [N, C]

Return type:

Tensor

forward(data)[source]

Applies the layer.

Parameters:

data (Tensor) – (tensor) input shape [N, C]

Return type:

Tensor

class TransformerBlockMLP(in_features, hidden_features=None, out_features=None, act_layer=GELU(approximate='none'), bias=True, drop=0.0)[source]

MLP as used in Vision Transformer, MLP-Mixer and related networks.

Init MLP.

Parameters:
  • in_features (int) – Number of input features.

  • hidden_features (int, optional) – Number of hidden features. Defaults to None.

  • out_features (int, optional) – Number of output features. Defaults to None.

  • act_layer (nn.Module, optional) – Activation layer. Defaults to nn.GELU.

  • bias (bool, optional) – If bias should be used. Defaults to True.

  • drop (float, optional) – Dropout probability. Defaults to 0.0.

__call__(data)[source]

Applies the layer.

Parameters:

data (Tensor) – (tensor) input shape [N, C]

Return type:

Tensor

forward(x)[source]

Forward pass.

Parameters:

x (Tensor) – (tensor) input shape [N, C]

Return type:

Tensor