module adabmDCA.training_config
Canonical configuration values and validation for DCA training.
Global Variables
- DEFAULT_PTT_MAX_EPOCHS
- DEFAULT_PTT_N_CHAINS
- DEFAULT_PTT_N_SWEEPS
- DEFAULT_PTT_SAMPLER
- MODEL_TYPES
- SAMPLERS
- DEFAULT_MODEL_TYPE
- DEFAULT_ALPHABET
- DEFAULT_LEARNING_RATE
- DEFAULT_N_SWEEPS
- DEFAULT_SAMPLER
- DEFAULT_N_CHAINS
- DEFAULT_TARGET_PEARSON
- DEFAULT_MAX_EPOCHS
- DEFAULT_L2_REGULARIZATION
- DEFAULT_SEED
- DEFAULT_CLUSTERING_SEQID
- DEFAULT_ACTIVATION_STEPS
- DEFAULT_ACTIVATION_FRACTION
- DEFAULT_TARGET_DENSITY
- DEFAULT_DECIMATION_RATE
- DEFAULT_DEVICE
- DEFAULT_DTYPE
- DEFAULT_CHECKPOINT_INTERVAL
- SPARSE_CHECKPOINT_INTERVAL
- DEFAULT_INNER_GRADIENT_STEPS
- EDGE_DEFAULT_PSEUDOCOUNT
- EDGE_EMPIRICAL_PSEUDOCOUNT
class ConfigurationError
Raised when a training configuration is internally inconsistent.
class TrainingConfig
All settings of one training run, validated on construction.
Pass it as config= to train_model; it then takes precedence over the function's individual keyword arguments. Settings that do not apply to the chosen model_type are ignored.
Attributes:
model_type:"bmDCA"(fully connected),"eaDCA"(coupling activation),"edDCA"(decimation) or"edgeDCA"(edge activation).alphabet:"protein","rna","dna"or an ordered custom token string.learning_rate: Step size of the parameter updates (ignored by edgeDCA).n_sweeps: Monte Carlo sweeps per update.sampler:"metropolized_gibbs","gibbs"or"metropolis".n_chains: Number of Markov chains.target_pearson: Training stops when the Pearson correlation between data and model connected correlations reaches this value.max_epochs: Step budget: gradient steps for bmDCA, graph steps for the sparse models. Superseded by the two limits below.max_gradient_steps: Optional limit on parameter updates.max_structure_steps: Optional limit on graph activations or decimations.pseudocount: Pseudocount of the training statistics;Nonemeans1/Meff(0.1 for edgeDCA).l2_regularization: Strength of the L2 penalty on the couplings.seed: Random seed.clustering_seqid: Sequence identity above which sequences share weight.no_reweighting: Give every training sequence the same weight.activation_steps: eaDCA: gradient updates between graph activations.activation_fraction: eaDCA: fraction of the inactive couplings activated per graph update (the upper limit for PTT adaptive activation).target_density: edDCA: coupling density at which decimation stops.decimation_rate: edDCA: fraction of active couplings removed per decimation.device:"auto","cpu","cuda"or"mps".dtype:"float32","float64"or"bfloat16"(CUDA/MPS; CUDA only with PTT).use_wandb: Log to Weights & Biases.checkpoint_interval: Updates between saved checkpoints;Noneuses the default.inner_gradient_steps: edDCA: largest number of gradient updates to re-converge the model after each decimation.edge_empirical_pseudocount: edgeDCA: small pseudocount of the target statistics, which avoids zero frequencies.ptt:PTTConfigto train with PTT, orNonefor PCD.
Raises:
ConfigurationError: If a setting is invalid or unsupported for the model.
Example:
config = TrainingConfig(model_type="eaDCA", alphabet="rna",
ptt=PTTConfig(activation="adaptive"))
train_model("family.fasta", config=config, output_dir="model")
method __init__
__init__(
model_type: 'str' = 'bmDCA',
alphabet: 'str' = 'protein',
learning_rate: 'float' = 0.01,
n_sweeps: 'int' = 10,
sampler: 'str' = 'metropolized_gibbs',
n_chains: 'int' = 2048,
target_pearson: 'float' = 0.95,
max_epochs: 'int' = 50000,
max_gradient_steps: 'int | None' = None,
max_structure_steps: 'int | None' = None,
pseudocount: 'float | None' = None,
l2_regularization: 'float' = 0.0,
seed: 'int' = 0,
clustering_seqid: 'float' = 0.8,
no_reweighting: 'bool' = False,
activation_steps: 'int' = 10,
activation_fraction: 'float' = 0.001,
target_density: 'float' = 0.02,
decimation_rate: 'float' = 0.01,
device: 'str' = 'auto',
dtype: 'str' = 'float32',
use_wandb: 'bool' = False,
checkpoint_interval: 'int | None' = 500,
inner_gradient_steps: 'int' = 10000,
edge_empirical_pseudocount: 'float' = 1e-06,
ptt: 'PTTConfig | None' = None
) → None
property empirical_pseudocount
Pseudocount used for target statistics before regularization.
property limits
Resolve the legacy epoch limit into explicit model-aware limits.
property resolved_checkpoint_interval
Checkpoint interval in updates, with the default filled in.
method as_dict
as_dict() → dict[str, Any]
Return a serializable snapshot suitable for run metadata.
method resolve_pseudocount
resolve_pseudocount(effective_size: 'float') → float
Return the pseudocount to use for a training set of effective_size (Meff).
Args:
effective_size: Sum of the training sequence weights.
Returns:
pseudocount if set; otherwise 0.1 for edgeDCA and 1/Meff for the other models.
Raises:
ConfigurationError: Ifeffective_sizeis not positive.
This file was automatically generated via lazydocs.