Skip to main content

LossFn

Trait LossFn 

Source
pub trait LossFn {
    // Required methods
    fn forward(&self, predictions: &Tensor, targets: &Tensor) -> Tensor;
    fn name(&self) -> &str;
}
Expand description

Trait for loss functions

Required Methods§

Source

fn forward(&self, predictions: &Tensor, targets: &Tensor) -> Tensor

Compute loss given predictions and targets

Returns a scalar loss value and sets up gradients for backpropagation

Source

fn name(&self) -> &str

Name of the loss function

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§