pub struct MultiTaskLoss {
pub task_losses: Vec<Box<dyn Loss>>,
pub task_weights: Vec<f64>,
pub strategy: TaskWeightingStrategy,
pub weight_lr: f64,
/* private fields */
}Expand description
Multi-task loss that combines multiple losses with configurable weighting.
Fields§
§task_losses: Vec<Box<dyn Loss>>Individual task losses.
task_weights: Vec<f64>Task weights (automatically managed based on strategy).
strategy: TaskWeightingStrategyWeighting strategy.
weight_lr: f64Learning rate for weight updates (used in some strategies).
Implementations§
Source§impl MultiTaskLoss
impl MultiTaskLoss
Sourcepub fn new_fixed(
task_losses: Vec<Box<dyn Loss>>,
task_weights: Vec<f64>,
) -> TrainResult<Self>
pub fn new_fixed( task_losses: Vec<Box<dyn Loss>>, task_weights: Vec<f64>, ) -> TrainResult<Self>
Create a new multi-task loss with fixed weights.
§Arguments
task_losses- Individual loss functions for each tasktask_weights- Fixed weights for each task (should sum to 1.0)
Sourcepub fn new_dynamic(
task_losses: Vec<Box<dyn Loss>>,
strategy: TaskWeightingStrategy,
weight_lr: f64,
) -> TrainResult<Self>
pub fn new_dynamic( task_losses: Vec<Box<dyn Loss>>, strategy: TaskWeightingStrategy, weight_lr: f64, ) -> TrainResult<Self>
Create a new multi-task loss with dynamic weighting.
§Arguments
task_losses- Individual loss functions for each taskstrategy- Weighting strategy to useweight_lr- Learning rate for weight updates
Sourcepub fn compute_multi_task(
&mut self,
predictions: &ArrayView<'_, f64, Ix2>,
targets: &ArrayView<'_, f64, Ix2>,
task_splits: &[usize],
) -> TrainResult<f64>
pub fn compute_multi_task( &mut self, predictions: &ArrayView<'_, f64, Ix2>, targets: &ArrayView<'_, f64, Ix2>, task_splits: &[usize], ) -> TrainResult<f64>
Sourcepub fn get_weights(&self) -> &[f64]
pub fn get_weights(&self) -> &[f64]
Get current task weights.
Auto Trait Implementations§
impl Freeze for MultiTaskLoss
impl !RefUnwindSafe for MultiTaskLoss
impl !Send for MultiTaskLoss
impl !Sync for MultiTaskLoss
impl Unpin for MultiTaskLoss
impl !UnwindSafe for MultiTaskLoss
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more