bonni.MLPModelConfig#
- class bonni.MLPModelConfig(*, num_layer, out_channels, hidden_channels=None, norm_groups=None, last_norm_groups=None, dropout_prob=0.0, last_dropout_prob=0.0, activation_type=ActivationType.gelu, different_last_activation=ActivationType.identity, bias_init=InitType.zeros, skip_if_possible=True)[source]#
Configuration object for a Multi-Layer Perceptron (MLP) model.
This dataclass defines the structural and hyperparameter settings for an MLP, including layer dimensions, normalization, dropout, and activation strategies. It is frozen (immutable) and requires keyword arguments for initialization.
- num_layer#
The total number of linear layers in the MLP.
- Type:
int
- out_channels#
The dimensionality of the output features.
- Type:
int
The dimensionality of the hidden layers. If None, this is typically inferred from the input or output channels depending on the implementation. Defaults to None.
- Type:
int | None
- norm_groups#
The number of groups to use for Group Normalization in the hidden layers. If None, normalization is skipped. Defaults to None.
- Type:
int | None
- last_norm_groups#
The number of groups for Group Normalization applied to the final layer. If None, no normalization is applied to the output. Defaults to None.
- Type:
int | None
- dropout_prob#
The dropout probability applied after hidden layers. Must be between 0.0 and 1.0. Defaults to 0.0.
- Type:
float
- last_dropout_prob#
The dropout probability applied after the final layer. Defaults to 0.0.
- Type:
float
- activation_type#
The activation function used after hidden layers. Defaults to ActivationType.gelu.
- Type:
- different_last_activation#
The activation function used after the final layer. If set to ActivationType.identity, the output is linear. If None, the model typically uses the same activation as activation_type. Defaults to ActivationType.identity.
- Type:
ActivationType | None
- bias_init#
The initialization strategy for the layer biases (e.g., zeros, uniform). Defaults to InitType.zeros.
- Type:
- skip_if_possible#
If True, adds residual connections (skip connections) around layers where the input and output dimensions are identical. Defaults to True.
- Type:
bool
- __init__(*, num_layer, out_channels, hidden_channels=None, norm_groups=None, last_norm_groups=None, dropout_prob=0.0, last_dropout_prob=0.0, activation_type=ActivationType.gelu, different_last_activation=ActivationType.identity, bias_init=InitType.zeros, skip_if_possible=True)#
Methods
__init__(*, num_layer, out_channels[, ...])Attributes