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:
device – device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
v – Ivy container of trainable variables. Created internally by default.
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.
trace_on_next_step – Whether to trace the network in a graph on the next forward pass. Default is
False
.store_vars – Whether or not to store the variables created. Default is
True
.stateful – The constant id stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.arg_stateful_idxs – The nested argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.kwarg_stateful_idxs – The nested keyword argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.fallback_to_non_traced – Whether to fall back to non-traced forward call in the case that an error is raised during the traced forward pass. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.training – specifies whether the module is in training or evaluation mode. Default is
True
.devices – devices on which to distribute the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
- 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:
device – device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
v – Ivy container of trainable variables. Created internally by default.
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.
trace_on_next_step – Whether to trace the network in a graph on the next forward pass. Default is
False
.store_vars – Whether or not to store the variables created. Default is
True
.stateful – The constant id stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.arg_stateful_idxs – The nested argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.kwarg_stateful_idxs – The nested keyword argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.fallback_to_non_traced – Whether to fall back to non-traced forward call in the case that an error is raised during the traced forward pass. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.training – specifies whether the module is in training or evaluation mode. Default is
True
.devices – devices on which to distribute the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
- 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:
device – device on which to create the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)
v – Ivy container of trainable variables. Created internally by default.
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.
trace_on_next_step – Whether to trace the network in a graph on the next forward pass. Default is
False
.store_vars – Whether or not to store the variables created. Default is
True
.stateful – The constant id stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.arg_stateful_idxs – The nested argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.kwarg_stateful_idxs – The nested keyword argument indices of stateful items to track as part of the forward pass. Used when graph compiling, default is
None
.fallback_to_non_traced – Whether to fall back to non-traced forward call in the case that an error is raised during the traced forward pass. Default is
True
.with_partial_v – Whether to allow partial specification of variables. Default is
False
.training – specifies whether the module is in training or evaluation mode. Default is
True
.devices – devices on which to distribute the module’s variables ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None)