multiml.task.pytorch.modules.mlp module

class multiml.task.pytorch.modules.mlp.MLPBlock(layers, activation, activation_last=None, batch_norm=False, initialize=True, input_shape=None, output_shape=None, *args, **kwargs)

Bases: Module

__init__(layers, activation, activation_last=None, batch_norm=False, initialize=True, input_shape=None, output_shape=None, *args, **kwargs)
Parameters:
  • layers (list) – list of hidden layers

  • activation (str) – activation function for MLP

  • activation_last (str) – activation function for the MLP last layer

  • batch_norm (bool) – use batch normalization

  • *args – Variable length argument list

  • **kwargs – Arbitrary keyword arguments

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool