yamle.losses.loss module#

class yamle.losses.loss.BaseLoss(reduction_per_member='mean', reduction_per_sample='mean', reduction_per_feature='none', task=None)[source]#

Bases: ABC

This is the base class for all losses.

Parameters:
  • reduction_per_member (str) – The reduction to be used for the loss. Given that the input has the shape (batch_size, num_members, …), the loss will be reduced over the num_members dimension.

  • reduction_per_sample (str) – The reduction to be used for the loss. Given that the input has the shape (batch_size, num_members, …), the loss will be reduced over the batch_size dimension.

  • reduction_per_feature (str) – The reduction to be used for the loss. Given that the input has the shape (batch_size, num_members, num_features, …), the loss will be reduced over the num_features dimension.

tasks = ['regression', 'classification', 'text_classification', 'segmentation', 'depth_estimation', 'pre_training', 'reconstruction']#
set_reduction_per_member(reduction_per_member)[source]#

This method is used to set the reduction per member.

Return type:

None

set_reduction_per_sample(reduction_per_sample)[source]#

This method is used to set the reduction per sample.

Return type:

None

set_reduction_per_feature(reduction_per_feature)[source]#

This method is used to set the reduction per feature.

Return type:

None

static add_specific_args(parent_parser)[source]#

This method is used to add the loss specific arguments to the parent parser.

Return type:

ArgumentParser

class yamle.losses.loss.DummyLoss(reduction_per_member='mean', reduction_per_sample='mean', reduction_per_feature='none', task=None)[source]#

Bases: BaseLoss

This is a dummy loss class which always returns 0.0 tensor.