pyprobound.loss.MultiExperimentLoss
- class MultiExperimentLoss(components, weights=None, lambda_l2=1e-06, lambda_l1=0, pseudocount=0, exponential_bound=40, full_loss=False, dilute_regularization=False, exclude_regularization=(), equalize_contribution=False, max_split=None)
Bases:
BaseLoss[CountBatch]Multitask optimization of multiple count tables with a Poisson loss.
- transforms
The experiments to be jointly optimized.
- Type:
- __init__(components, weights=None, lambda_l2=1e-06, lambda_l1=0, pseudocount=0, exponential_bound=40, full_loss=False, dilute_regularization=False, exclude_regularization=(), equalize_contribution=False, max_split=None)
Initializes the multitask loss from an iterable of experiments.
- Parameters:
components (
Iterable[Experiment]) – The experiments to be jointly optimized.weights (
Iterable[float] |None) – Multiplier to the NLL of each corresponding experiment.lambda_l2 (
float) – L2 regularization hyperparameter.lambda_l1 (
float) – L1 regularization hyperparameter.pseudocount (
float) – Scaling factor for Dirichlet-inspired regularization.exponential_bound (
float) – Value of exponential barrier.full_loss (
bool) – Whether to compute the constant terms of the NLL.dilute_regularization (
bool) – Whether to keep hyperparameters fixed as the number of experiments 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
unfreezablealias of
Literal['all']Non-Inherited Members
- regularization(component)
Calculates parameter regularization.
- Parameters:
transform – The component containing parameters to be regularized.
- Return type:
Tensor- Returns:
The regularization value as a scalar tensor.
- 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,Tensor]- 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.