loss_factory
Loss factory module.
This module contains a factory function for creating loss functions.
FCNLossParameters
dataclass
#
LVAELossParameters
dataclass
#
Dataclass for LVAE loss.
Source code in src/careamics/losses/loss_factory.py
current_epoch: int = 0
class-attribute
instance-attribute
#
Current epoch in the training loop.
denoisplit_weight: float = 0.9
class-attribute
instance-attribute
#
Weight for the denoiSplit loss (used in the muSplit-deonoiSplit loss).
gaussian_likelihood: Optional[GaussianLikelihood] = None
class-attribute
instance-attribute
#
Gaussian likelihood instance.
kl_annealing: bool = False
class-attribute
instance-attribute
#
Whether to apply KL loss annealing.
kl_annealtime: int = 10
class-attribute
instance-attribute
#
Number of epochs for which KL loss annealing is applied.
kl_start: int = -1
class-attribute
instance-attribute
#
Epoch at which KL loss annealing starts.
kl_type: Literal['kl', 'kl_restricted', 'kl_spatial', 'kl_channelwise'] = 'kl'
class-attribute
instance-attribute
#
Type of KL divergence used as KL loss.
kl_weight: float = 1.0
class-attribute
instance-attribute
#
Weight for the KL loss in the total net loss. (i.e., net_loss = reconstruction_weight * rec_loss + kl_weight * kl_loss
).
musplit_weight: float = 0.1
class-attribute
instance-attribute
#
Weight for the muSplit loss (used in the muSplit-denoiSplit loss).
noise_model_likelihood: Optional[NoiseModelLikelihood] = None
class-attribute
instance-attribute
#
Noise model likelihood instance.
non_stochastic: bool = False
class-attribute
instance-attribute
#
Whether to sample latents and compute KL.
reconstruction_weight: float = 1.0
class-attribute
instance-attribute
#
Weight for the reconstruction loss in the total net loss (i.e., net_loss = reconstruction_weight * rec_loss + kl_weight * kl_loss
).
loss_factory(loss)
#
Return loss function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
loss | Union[SupportedLoss, str] | Requested loss. | required |
Returns:
Type | Description |
---|---|
Callable | Loss function. |
Raises:
Type | Description |
---|---|
NotImplementedError | If the loss is unknown. |
Source code in src/careamics/losses/loss_factory.py
loss_parameters_factory(type)
#
Return loss parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type | SupportedLoss | Requested loss. | required |
Returns:
Type | Description |
---|---|
Union[FCNLossParameters, LVAELossParameters] | Loss parameters. |
Raises:
Type | Description |
---|---|
NotImplementedError | If the loss is unknown. |