xnn.common.models.blocks.MLP#
- class xnn.common.models.blocks.MLP(sizes, activation='gelu', activate_last=False, bias=True)[source]#
Bases:
ModuleA stack of dense layers with one activation between consecutive layers.
- Parameters:
sizes (sequence of int) – Feature sizes from the input to the output, at least two.
activation (str or torch.nn.Module, optional) – Activation (see
make_activation()), by default"gelu".activate_last (bool, optional) – Apply the activation after the last layer too. Default
False.bias (bool, optional) – Give the layers biases. Default
True.
- forward(x)[source]#
Define 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
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.