pyprobound.loss.MultiRoundMSLELoss

class MultiRoundMSLELoss(components, weights=None, lambda_l2=1e-06, lambda_l1=0, exponential_bound=40, dilute_regularization=False, exclude_regularization=(), equalize_contribution=False, max_split=None)

Bases: BaseLoss[CountBatch]

Multitask optimization of intensity experiments with a MSLE loss.

transforms

The rounds to be jointly optimized.

Type:

TModuleList[BaseRound]

__init__(components, weights=None, lambda_l2=1e-06, lambda_l1=0, exponential_bound=40, dilute_regularization=False, exclude_regularization=(), equalize_contribution=False, max_split=None)

Initializes the multitask loss from an iterable of components.

Parameters:
  • transforms – The components to be jointly optimized.

  • weights (Iterable[float] | None) – Multiplier to the NLL of each corresponding component.

  • lambda_l2 (float) – L2 regularization hyperparameter.

  • lambda_l1 (float) – L1 regularization hyperparameter.

  • exponential_bound (float) – Value of exponential barrier.

  • dilute_regularization (bool) – Whether to keep hyperparameters fixed as the number of components increases.

  • exclude_regularization (Iterable[str]) – Keywords used to exclude parameters from regularization.

  • equalize_contribution (bool) – Whether to update the weights so that the rescaled losses are constant relative to each other.

  • max_split (int | None) – Maximum number of sequences scored at a time.

Methods

check_length_consistency()

Checks that input lengths of Binding components are consistent.

components()

Iterator of child components.

forward(batches)

Calculates the multitask weighted loss and regularization.

freeze()

Turns off gradient calculation for all parameters.

get_setup_string()

A description used when printing the output of an optimizer.

max_embedding_size()

The maximum number of bytes needed to encode a sequence.

negloglik(transform, batch)

Calculates the negative log-likelihood plus a normalization factor.

optim_procedure([ancestry, current_order])

The sequential optimization procedure for all Binding components.

regularization(component)

Calculates parameter regularization.

reload(checkpoint)

Loads the model from a checkpoint file.

reload_from_state_dict(state_dict)

Loads the model from a state dict.

save(checkpoint[, flank_lengths])

Saves the model to a file with "state_dict" and "metadata" fields.

unfreeze([parameter])

Turns on gradient calculation for the specified parameter.

Attributes

unfreezable

alias of Literal['all']

Non-Inherited Members

negloglik(transform, batch)

Calculates the negative log-likelihood plus a normalization factor.

Parameters:
  • transform (Transform) – The component used for scoring.

  • batch (CountBatch) – The batch to be scored.

Return type:

tuple[Tensor, int]

Returns:

A tuple of scalar tensors (negloglik, norm), where negloglik is the negative log-likelihood of the batch and norm is a scaling factor. A running sum of each is kept, and the loss is the ratio.