Configuration class for CrossEntropy module.
More...
Configuration class for CrossEntropy module.
◆ CrossEntropyConfig()
| 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 possible classes) |
◆ getClassWeights()
| const std::vector< float > & Mila::Dnn::CrossEntropyConfig::getClassWeights |
( |
| ) |
const |
|
inline |
◆ getLabelSmoothing()
| float Mila::Dnn::CrossEntropyConfig::getLabelSmoothing |
( |
| ) |
const |
|
inline |
Get the label smoothing factor.
◆ getPaddingIndex()
| int64_t Mila::Dnn::CrossEntropyConfig::getPaddingIndex |
( |
| ) |
const |
|
inline |
◆ getReduction()
| bool Mila::Dnn::CrossEntropyConfig::getReduction |
( |
| ) |
const |
|
inline |
Check if loss should be reduced.
◆ getVocabSize()
| int64_t Mila::Dnn::CrossEntropyConfig::getVocabSize |
( |
| ) |
const |
|
inline |
◆ ignorePadding()
| bool Mila::Dnn::CrossEntropyConfig::ignorePadding |
( |
| ) |
const |
|
inline |
Check if padding should be ignored.
◆ validate()
| void Mila::Dnn::CrossEntropyConfig::validate |
( |
| ) |
const |
|
inlinevirtual |
Validate configuration parameters.
- Exceptions
-
| std::invalid_argument | If validation fails |
Reimplemented from Mila::Dnn::ComponentConfig.
◆ withClassWeights()
| CrossEntropyConfig & Mila::Dnn::CrossEntropyConfig::withClassWeights |
( |
const std::vector< float > & |
weights | ) |
|
|
inline |
Set class weights for weighted cross entropy.
- Parameters
-
| weights | Vector of weights for each class |
- Returns
- CrossEntropyConfig& Reference to this for method chaining
◆ withIgnorePadding()
Configure whether to ignore padding index.
When true, targets with the specified padding index will not contribute to the loss.
- Parameters
-
| ignore_pad | Enable padding index ignoring |
- Returns
- CrossEntropyConfig& Reference to this for method chaining
◆ withLabelSmoothing()
Configure whether to apply label smoothing.
- Parameters
-
| smoothing | Label smoothing factor (0.0 to 1.0) |
- Returns
- CrossEntropyConfig& Reference to this for method chaining
◆ withPaddingIndex()
Set the padding index to ignore.
- Parameters
-
| pad_idx | The padding index value to ignore in loss calculation |
- Returns
- CrossEntropyConfig& Reference to this for method chaining
◆ withReduction()
Configure whether to reduce the loss.
When true, returns the mean of losses. When false, returns per-sample losses.
- Parameters
-
| reduce | Whether to average the loss |
- Returns
- CrossEntropyConfig& Reference to this for method chaining
◆ class_weights_
| std::vector<float> Mila::Dnn::CrossEntropyConfig::class_weights_ |
|
private |
◆ ignore_padding_
| bool Mila::Dnn::CrossEntropyConfig::ignore_padding_ = false |
|
private |
◆ label_smoothing_
| float Mila::Dnn::CrossEntropyConfig::label_smoothing_ = 0.0f |
|
private |
◆ padding_idx_
| int64_t Mila::Dnn::CrossEntropyConfig::padding_idx_ = -1 |
|
private |
◆ reduce_
| bool Mila::Dnn::CrossEntropyConfig::reduce_ = true |
|
private |
◆ vocab_size_
| int64_t Mila::Dnn::CrossEntropyConfig::vocab_size_ |
|
private |
The documentation for this class was generated from the following file: