pub struct CrossEntropyLossConfig {
pub output_logits: bool,
pub target_logits: bool,
}Expand description
Configuration to create a Cross-entropy loss using the init function.
Fields§
§output_logits: boolTreat the outputs as logits, applying log-softmax when computing the loss.
When false, outputs are assumed to be probabilities (e.g. post-softmax).
target_logits: boolTreat the targets as logits, applying softmax to normalize them before computing the loss.
When false, targets are assumed to already be a valid probability distribution
(e.g. one-hot or soft labels that sum to 1).
Implementations§
Source§impl CrossEntropyLossConfig
impl CrossEntropyLossConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new instance of the config.
§Arguments
§Default Arguments
§output_logits
Treat the outputs as logits, applying log-softmax when computing the loss.
When false, outputs are assumed to be probabilities (e.g. post-softmax).
- Defaults to
true
§target_logits
Treat the targets as logits, applying softmax to normalize them before computing the loss.
When false, targets are assumed to already be a valid probability distribution
(e.g. one-hot or soft labels that sum to 1).
- Defaults to
false
Source§impl CrossEntropyLossConfig
impl CrossEntropyLossConfig
Sourcepub fn with_output_logits(self, output_logits: bool) -> Self
pub fn with_output_logits(self, output_logits: bool) -> Self
Sets the value for the field output_logits.
Treat the outputs as logits, applying log-softmax when computing the loss.
When false, outputs are assumed to be probabilities (e.g. post-softmax).
- Defaults to
true
Sourcepub fn with_target_logits(self, target_logits: bool) -> Self
pub fn with_target_logits(self, target_logits: bool) -> Self
Sets the value for the field target_logits.
Treat the targets as logits, applying softmax to normalize them before computing the loss.
When false, targets are assumed to already be a valid probability distribution
(e.g. one-hot or soft labels that sum to 1).
- Defaults to
false
Source§impl CrossEntropyLossConfig
impl CrossEntropyLossConfig
Sourcepub fn init(&self) -> CrossEntropyLoss
pub fn init(&self) -> CrossEntropyLoss
Initialize Cross-entropy loss.