Configuration class for the Multi-Layer Perceptron (MLP) block.
More...
Configuration class for the Multi-Layer Perceptron (MLP) block.
MLPConfig specifies the architectural parameters for an MLP block:
- Input and hidden feature dimensions
- Activation function type
- Optional bias and layer normalization
The MLP block structure is: Input -> Linear(in_features, hidden_size) -> [LayerNorm] -> Activation -> Linear(hidden_size, in_features) -> Output
◆ MLPConfig()
| Mila::Dnn::MLPConfig::MLPConfig |
( |
dim_t | input_features, |
|
|
dim_t | hidden_size ) |
|
inline |
Construct MLP configuration.
- Parameters
-
| input_features | Number of input (and output) features (must be > 0). |
| hidden_size | Size of the intermediate hidden layer (must be > 0). |
◆ fromMetadata()
Populate configuration from provided metadata.
Missing keys are ignored. Type-safe try-get helpers are used to avoid throwing on absent fields and to preserve forward/backward compatibility.
- Parameters
-
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
◆ getActivationType()
Get the configured activation function type.
- Returns
- ActivationType selected for the MLP.
◆ getHiddenSize()
| dim_t Mila::Dnn::MLPConfig::getHiddenSize |
( |
| ) |
const |
|
inlinenoexcept |
Get the hidden layer size.
- Returns
- Hidden layer dimension.
◆ getInputFeatures()
| dim_t Mila::Dnn::MLPConfig::getInputFeatures |
( |
| ) |
const |
|
inlinenoexcept |
Get the configured number of input (and output) features.
- Returns
- Number of input features.
◆ hasBias()
| bool Mila::Dnn::MLPConfig::hasBias |
( |
| ) |
const |
|
inlinenoexcept |
Query whether linear layers include bias terms.
- Returns
- True if bias is enabled.
◆ toMetadata()
◆ toString()
| std::string Mila::Dnn::MLPConfig::toString |
( |
| ) |
const |
|
inlineoverridevirtual |
Produce a short, human-readable summary of the configuration.
Implementations should return a compact, single-line description suitable for logging and debugging.
- Returns
- std::string Human-readable summary of the configuration.
Implements Mila::Dnn::ComponentConfig.
◆ validate()
| void Mila::Dnn::MLPConfig::validate |
( |
| ) |
const |
|
inlineoverridevirtual |
Validate configuration parameters.
- Exceptions
-
| std::invalid_argument | If validation fails (e.g. zero-sized dimensions). |
Implements Mila::Dnn::ComponentConfig.
◆ withActivation()
template<typename Self>
| decltype(auto) Mila::Dnn::MLPConfig::withActivation |
( |
this Self && | self, |
|
|
ActivationType | activation ) |
|
inline |
Set the activation function type (C++23 fluent style).
◆ withBias()
template<typename Self>
| Self && Mila::Dnn::MLPConfig::withBias |
( |
this Self && | self, |
|
|
bool | has_bias ) |
|
inline |
Configure whether the linear layers use bias.
- Parameters
-
| has_bias | True to include bias terms in linear layers, false to omit. |
- Returns
- Self forwarding reference for method chaining.
◆ activation_type_
◆ has_bias_
| bool Mila::Dnn::MLPConfig::has_bias_ { true } |
|
private |
◆ hidden_size_
| dim_t Mila::Dnn::MLPConfig::hidden_size_ { 0 } |
|
private |
◆ input_features_
| dim_t Mila::Dnn::MLPConfig::input_features_ { 0 } |
|
private |
The documentation for this class was generated from the following file: