|
Mila
Deep Neural Network Library
|
Configuration for fused SoftmaxCrossEntropy loss. More...
Public Member Functions | |
| CrossEntropyConfig ()=default | |
| Default constructor. | |
| CrossEntropyConfig (int64_t vocab_size) | |
| Constructor with required vocabulary size parameter. | |
| void | fromMetadata (const SerializationMetadata &meta) override |
| Populate configuration from provided metadata. | |
| int64_t | getVocabSize () const |
| Get the vocabulary size. | |
| SerializationMetadata | toMetadata () const override |
| Convert configuration into SerializationMetadata. | |
| std::string | toString () const override |
| String representation of the configuration. | |
| void | validate () const override |
| Validate configuration parameters. | |
| template<typename Self> | |
| decltype(auto) | withVocabSize (this Self &&self, int64_t vocab_size) |
| C++23-style fluent setter for vocabulary size. | |
| Public Member Functions inherited from Mila::Dnn::ComponentConfig | |
| virtual | ~ComponentConfig ()=default |
| Virtual destructor for polymorphic base. | |
Configuration for fused SoftmaxCrossEntropy loss.
Provides a lightweight value object containing the vocabulary size required by the fused softmax + cross-entropy kernels.
|
default |
Default constructor.
Leaves vocab_size_ at 0; callers should set it before using the configuration. validate() will reject a zero vocab size.
|
inlineexplicit |
Constructor with required vocabulary size parameter.
| vocab_size | The size of the vocabulary (number of classes). Must be > 0. Kernels validate: 0 <= target < vocab_size. |
|
inlineoverridevirtual |
Populate configuration from provided metadata.
Missing keys are ignored, leaving defaults intact. Type-safe try-get helpers are used to avoid throwing on absent fields.
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
|
inline |
Get the vocabulary size.
Used by kernels to validate target indices.
|
inlineoverridevirtual |
Convert configuration into SerializationMetadata.
Produces keys:
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
String representation of the configuration.
Implements Mila::Dnn::ComponentConfig.
|
inlineoverridevirtual |
Validate configuration parameters.
Checks that vocabulary size is positive.
| std::invalid_argument | If vocab_size <= 0 |
Implements Mila::Dnn::ComponentConfig.
|
inline |
C++23-style fluent setter for vocabulary size.
| vocab_size | Vocabulary size (number of classes) |