Losses#
Collection of Ivy’s losses as stateful classes.
- class ivy.stateful.losses.BinaryCrossEntropyLoss(*, from_logits=False, epsilon=0.0, reduction='none')[source]#
Bases:
Module
- __init__(*, from_logits=False, epsilon=0.0, reduction='none')[source]#
Initialize Ivy layer, which is a stateful object consisting of trainable variables.
- Parameters:
args – Positional arguments to the _build method.
v – Ivy container of trainable variables. Created internally by default.
buffers – Ivy container of buffers/non-trainable arrays in the state_dict.
build_mode – How the Module is built, either on initialization (now), explicitly by the user by calling build(), or the first time the __call__ method is run. Default is on initialization.
store_vars – Whether or not to store the variables created. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.dynamic_backend – When the value is true, allow conversion of arrays from a different backend to the current backend if v passed in the input contains arrays created with different backend.
training – specifies whether the module is in training or evaluation mode. Default is
True
.dtype – Data type to be used for creating model variables. (Default value = None).
device – Device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).
kwargs – Keyword arguments to the _build method.
- class ivy.stateful.losses.CrossEntropyLoss(*, axis=-1, epsilon=1e-07, reduction='sum')[source]#
Bases:
Module
- __init__(*, axis=-1, epsilon=1e-07, reduction='sum')[source]#
Initialize Ivy layer, which is a stateful object consisting of trainable variables.
- Parameters:
args – Positional arguments to the _build method.
v – Ivy container of trainable variables. Created internally by default.
buffers – Ivy container of buffers/non-trainable arrays in the state_dict.
build_mode – How the Module is built, either on initialization (now), explicitly by the user by calling build(), or the first time the __call__ method is run. Default is on initialization.
store_vars – Whether or not to store the variables created. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.dynamic_backend – When the value is true, allow conversion of arrays from a different backend to the current backend if v passed in the input contains arrays created with different backend.
training – specifies whether the module is in training or evaluation mode. Default is
True
.dtype – Data type to be used for creating model variables. (Default value = None).
device – Device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).
kwargs – Keyword arguments to the _build method.
- class ivy.stateful.losses.LogPoissonLoss(*, compute_full_loss=False, axis=-1, reduction='none')[source]#
Bases:
Module
- __init__(*, compute_full_loss=False, axis=-1, reduction='none')[source]#
Initialize Ivy layer, which is a stateful object consisting of trainable variables.
- Parameters:
args – Positional arguments to the _build method.
v – Ivy container of trainable variables. Created internally by default.
buffers – Ivy container of buffers/non-trainable arrays in the state_dict.
build_mode – How the Module is built, either on initialization (now), explicitly by the user by calling build(), or the first time the __call__ method is run. Default is on initialization.
store_vars – Whether or not to store the variables created. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.dynamic_backend – When the value is true, allow conversion of arrays from a different backend to the current backend if v passed in the input contains arrays created with different backend.
training – specifies whether the module is in training or evaluation mode. Default is
True
.dtype – Data type to be used for creating model variables. (Default value = None).
device – Device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).
kwargs – Keyword arguments to the _build method.
This should have hopefully given you an overview of the losses submodule, if you have any questions, please feel free to reach out on our discord!