cyto_dl.nn.losses.loss_wrapper module#

class cyto_dl.nn.losses.loss_wrapper.CMAP_loss(loss)[source]#

Bases: Module

Loss Wrapper for losses that accept a spatial costmap, differentially emphasizing pixel losses throughout an image.

Parameters:

loss – Loss function. Should provide per-pixel losses.

class cyto_dl.nn.losses.loss_wrapper.LossWrapper(loss_fn, channel_weight: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], loss_scale: float = 1.0)[source]#

Bases: Module

Loss Wrapper for weighting loss between channels differently. loss_fn is calculated per-channel, scaled by channel_weight, averaged, and scaled by loss_scale

Parameters:
  • loss_fn – Loss function

  • channel_weight (ArrayLike) – array of floats with length equal to number of channels of predicted image

  • loss_scale (float) – Scale for channel-weighted loss.