pub struct CrossEntropyLoss { /* private fields */ }
Expand description

Cross-entropy loss function.

Implementations§

Construct the cross-entropy loss function.

Do not include targets that have ignore_index as their value in the loss computation. If label_smoothing is set to p, then the correct label gets probability 1-p and the probability p is distributed across incorrect labels. reduction specifies how the losses should be reduced/summarized.

Compute the cross-entropy loss.

logits should be the unnormalized probablilities of shape [batch_size, n_classes] and targets the gold-standard labels with shape [batch_size].

The optional target mask has to be of shape [batch_size, n_classes]. If the mask is not provided, then all n_classes will be used in label smoothing.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.