Configuration for fused SoftmaxCrossEntropy loss.
More...
|
| int64_t | vocab_size_ = 0 |
| | Number of classes in the vocabulary.
|
Configuration for fused SoftmaxCrossEntropy loss.
Provides a lightweight value object containing the vocabulary size required by the fused softmax + cross-entropy kernels.
◆ CrossEntropyConfig() [1/2]
| Mila::Dnn::CrossEntropyConfig::CrossEntropyConfig |
( |
| ) |
|
|
default |
Default constructor.
Leaves vocab_size_ at 0; callers should set it before using the configuration. validate() will reject a zero vocab size.
◆ CrossEntropyConfig() [2/2]
| Mila::Dnn::CrossEntropyConfig::CrossEntropyConfig |
( |
int64_t | vocab_size | ) |
|
|
inlineexplicit |
Constructor with required vocabulary size parameter.
- Parameters
-
| vocab_size | The size of the vocabulary (number of classes). Must be > 0. Kernels validate: 0 <= target < vocab_size. |
◆ fromMetadata()
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.
- Parameters
-
| meta | Metadata to read configuration values from. |
Implements Mila::Dnn::ComponentConfig.
◆ getVocabSize()
| int64_t Mila::Dnn::CrossEntropyConfig::getVocabSize |
( |
| ) |
const |
|
inline |
Get the vocabulary size.
Used by kernels to validate target indices.
- Returns
- int64_t The vocabulary size
◆ toMetadata()
◆ toString()
| std::string Mila::Dnn::CrossEntropyConfig::toString |
( |
| ) |
const |
|
inlineoverridevirtual |
String representation of the configuration.
- Returns
- std::string Human-readable description of the configuration.
Implements Mila::Dnn::ComponentConfig.
◆ validate()
| void Mila::Dnn::CrossEntropyConfig::validate |
( |
| ) |
const |
|
inlineoverridevirtual |
Validate configuration parameters.
Checks that vocabulary size is positive.
- Exceptions
-
| std::invalid_argument | If vocab_size <= 0 |
Implements Mila::Dnn::ComponentConfig.
◆ withVocabSize()
template<typename Self>
| decltype(auto) Mila::Dnn::CrossEntropyConfig::withVocabSize |
( |
this Self && | self, |
|
|
int64_t | vocab_size ) |
|
inline |
C++23-style fluent setter for vocabulary size.
- Parameters
-
| vocab_size | Vocabulary size (number of classes) |
- Returns
- Self&& for method chaining
◆ vocab_size_
| int64_t Mila::Dnn::CrossEntropyConfig::vocab_size_ = 0 |
|
private |
Number of classes in the vocabulary.
The documentation for this class was generated from the following file: