xnn.common.config.schema.OptimConfig#
- class xnn.common.config.schema.OptimConfig(lr=0.001, weight_decay=0.0, epochs=100, energy_weight=1.0, force_weight=10.0, stress_weight=0.0, dipole_weight=0.0, polarizability_weight=0.0, charge_weight=0.0, les_dipole_weight=0.0, les_charge_weight=0.0, scheduler='plateau', huber_delta=0.0, huber_delta_energy=None, huber_delta_forces=None, huber_delta_stress=None, optimizer='adam', clip_grad=0.0, ema_decay=0.0, head_weights=None, freeze=<factory>, train_only=<factory>)[source]#
Bases:
objectOptimizer, schedule, and loss-weighting settings.
- Variables:
lr (float) – Learning rate. Defaults to
1e-3.weight_decay (float) – L2 weight-decay coefficient. Defaults to
0.0.epochs (int) – Number of training epochs. MACE
max_num_epochs. Defaults to100.energy_weight (float) – Weight of the energy term in the loss. MACE
energy_weight. Defaults to1.0.force_weight (float) – Weight of the force term in the loss. Defaults to
10.0.stress_weight (float) – Weight of the stress term; values
> 0enable stress training for periodic systems. Defaults to0.0.dipole_weight (float) – Weight of the dipole-moment term, for models with a dipole output (PaiNN, PhysNet, AIMNet2) on data with
dipolelabels. Defaults to0.0.polarizability_weight (float) – Weight of the polarizability-tensor term (PaiNN). Defaults to
0.0.charge_weight (float) – Weight of the per-atom partial-charge term, for models with a
chargesoutput (the 3G / 4G HDNNP charge networks, PhysNet, AIMNet2) on data withchargeslabels. Defaults to0.0.les_dipole_weight (float) – Weight of the LES dipole term: the
les_dipoleof a model wrapped inLatentEwaldagainst thedipolelabels. Defaults to0.0.les_charge_weight (float) – Weight of the LES charge term:
les_chargesagainst thechargeslabels. Defaults to0.0.scheduler (str) – Learning-rate scheduler (
none/cosine/plateau). MACE usesReduceLROnPlateau. Defaults to"plateau".huber_delta (float) – Crossover from quadratic to linear in the loss, which caps the pull of a few large residuals.
0.0(the default) is plain squared error. Note xnn scales the Huber function to agree with the squared error belowdelta, so the loss weights keep their meaning when it is switched on; MACE uses the textbook half-square form.huber_delta_energy (float, optional) – Per-term override of
huber_deltafor the energy term.None(default) falls back to it. Energies (eV per atom) and forces (eV/A) differ in scale by an order of magnitude, so one delta rarely suits both.huber_delta_forces (float, optional) – Per-term override of
huber_deltafor the force term.huber_delta_stress (float, optional) – Per-term override of
huber_deltafor the stress term.optimizer (str) –
"adam"(default;weight_decayis an L2 penalty),"amsgrad"(Adam with the AMSGrad maximum of the second moment, whose steps shrink as training settles; the DimeNet papers’ choice) or"adamw"(decoupled weight decay, the fine-tuning protocols’ choice).clip_grad (float) – Maximum gradient norm per step (
torch.nn.utils.clip_grad_norm_);0.0(default) disables clipping.ema_decay (float) – Decay of an exponential moving average of the weights, updated after every optimizer step and used for validation, testing and the saved checkpoints (
0.99-0.9999in the fine-tuning protocols).0.0(default) trains and saves the raw weights.head_weights (dict, optional) – Per-head loss weights of a multi-head model, e.g.
{"pt_head": {"energy_weight": 1.0, "force_weight": 10.0}}; a head not listed uses the global weights. Each head’s terms are averaged over its own structures and the heads are summed.freeze (list of str) –
fnmatchpatterns of parameter names to freeze (layer-freezing fine-tuning), e.g.["model.node_embedding*", "model.interactions.0.*"].train_only (list of str) – Patterns of the only parameters to train; everything else is frozen (
["*readouts*", "*atom_ref*"]trains the readout alone).
- Parameters:
lr (float)
weight_decay (float)
epochs (int)
energy_weight (float)
force_weight (float)
stress_weight (float)
dipole_weight (float)
polarizability_weight (float)
charge_weight (float)
les_dipole_weight (float)
les_charge_weight (float)
scheduler (str)
huber_delta (float)
huber_delta_energy (float | None)
huber_delta_forces (float | None)
huber_delta_stress (float | None)
optimizer (str)
clip_grad (float)
ema_decay (float)