|
Mila
Deep Neural Network Library
|
Configuration class for the Multi-Layer Perceptron (MLP) block. More...
Public Member Functions | |
| MLPConfig (dim_t input_features, dim_t hidden_size) | |
| Construct MLP configuration. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| ActivationType | getActivationType () const noexcept |
| Get the configured activation function type. | |
| dim_t | getHiddenSize () const noexcept |
| Get the hidden layer size. | |
| dim_t | getInputFeatures () const noexcept |
| Get the configured number of input (and output) features. | |
| bool | hasBias () const noexcept |
| Query whether linear layers include bias terms. | |
| SerializationMetadata | toMetadata () const override |
| Convert configuration into SerializationMetadata. | |
| std::string | toString () const override |
| Produce a short, human-readable summary of the configuration. | |
| void | validate () const override |
| Validate configuration parameters. | |
| template<typename Self> | |
| decltype(auto) | withActivation (this Self &&self, ActivationType activation) |
| Set the activation function type (C++23 fluent style). | |
| template<typename Self> | |
| Self && | withBias (this Self &&self, bool has_bias) |
| Configure whether the linear layers use bias. | |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
Configuration class for the Multi-Layer Perceptron (MLP) block.
MLPConfig specifies the architectural parameters for an MLP block:
The MLP block structure is: Input -> Linear(in_features, hidden_size) -> [LayerNorm] -> Activation -> Linear(hidden_size, in_features) -> Output
Construct MLP configuration.
| input_features | Number of input (and output) features (must be > 0). |
| hidden_size | Size of the intermediate hidden layer (must be > 0). |
|
inlineoverridevirtual |
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.
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
|
inlinenoexcept |
Get the configured activation function type.
|
inlinenoexcept |
Get the hidden layer size.
|
inlinenoexcept |
Get the configured number of input (and output) features.
|
inlinenoexcept |
Query whether linear layers include bias terms.
|
inlineoverridevirtual |
Convert configuration into SerializationMetadata.
Produces keys:
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Produce a short, human-readable summary of the configuration.
Implementations should return a compact, single-line description suitable for logging and debugging.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Validate configuration parameters.
| std::invalid_argument | If validation fails (e.g. zero-sized dimensions). |
Implements Mila::Dnn::ComponentConfig.
|
inline |
Configure whether the linear layers use bias.
| has_bias | True to include bias terms in linear layers, false to omit. |