bimodal_symmetric: Minimal distance from 2 modes#

bimodal_symmetric#

hypercoil.loss.bimodal_symmetric(X: Tensor, *, modes: Tuple[int, int] = (0, 1), key: PRNGKey | None = None)[source]#

Bimodal symmetric score function.

This function returns a score equal to the absolute difference between each element of the input tensor and whichever of the two specified modes is closer. Penalising this quantity can be used to concentrate weights at two modes, for instance 0 and 1 or -1 and 1.

Parameters:
XTensor

Input tensor.

modestuple(float, float) (default (0, 1))

Modes of the loss.

BimodalSymmetricLoss#

class hypercoil.loss.BimodalSymmetricLoss(nu: float = 1.0, name: str | None = None, *, modes: Tuple[int, int] = (0, 1), scalarisation: Callable | None = None, key: 'jax.random.PRNGKey' | None = None)[source]#

Loss based on the minimum distance from either of two modes.

This function returns a score equal to the absolute difference between each element of the input tensor and whichever of the two specified modes is closer. Penalising this quantity can be used to concentrate weights at two modes, for instance 0 and 1 or -1 and 1.

Parameters:
name: str

Designated name of the loss function. It is not required that this be specified, but it is recommended to ensure that the loss function can be identified in the context of a reporting utilities. If not explicitly specified, the name will be inferred from the class name and the name of the scoring function.

nu: float

Loss strength multiplier. This is a scalar multiplier that is applied to the loss value before it is returned. This can be used to modulate the relative contributions of different loss functions to the overall loss value. It can also be used to implement a schedule for the loss function, by dynamically adjusting the multiplier over the course of training.

modestuple(float, float) (default (0, 1))

Modes of the loss.

scalarisation: Callable

The scalarisation function to be used to aggregate the values returned by the scoring function. This function should take a single argument, which is a tensor of arbitrary shape, and return a single scalar value. By default, the mean scalarisation is used.

Methods

__call__(X, *[, key])

Call self as a function.