xnn.common.train.reactions.ReactionSet#
- class xnn.common.train.reactions.ReactionSet(structures, reactions, units='eV')[source]#
Bases:
objectReactions over a list of species structures.
- Parameters:
structures (sequence of dict) – The species, structure dicts as
structure_to_graph()takes them, each with a"name"(and optionally a"subset", which together key the species).reactions (sequence of dict) – One record per reaction:
"species"(names),"stoichiometry"(signed coefficients),"reference"(the reaction energy), optionally"subset"(the species are looked up under it),"weight"and"scale"(seereaction_energy_loss()).units (str, optional) – Units of the references:
"eV"(default),"kcal/mol"or"hartree"; they are kept in eV.
- Variables:
- classmethod from_gmtkn55(data, wtmad2=False, scale=56.84)[source]#
The reactions of
load_dataset("gmtkn55")(references in kcal/mol).- Parameters:
data (dict) –
{"structures": [...], "reactions": [...]}as the dataset returns them.wtmad2 (bool, optional) – Scale the errors of every set by
scale / <|dE|>(its mean absolute reference energy), the weighting of WTMAD-2; defaultFalse.scale (float, optional) – The constant of that weighting in kcal/mol; default 56.84 (the paper’s).
- Return type:
- subset(reactions)[source]#
The given reactions with the species they need (in the order first met).
- Parameters:
- Return type:
- graphs(cutoff)[source]#
The species as graphs with neighbor lists of radius
cutoff(built once per radius).- Parameters:
cutoff (float)
- Return type:
- batches(size, shuffle=True, seed=0)[source]#
Mini-batches of
sizereactions covering the set once (shuffled byseed), each asubset()with the species it needs.- Parameters:
- Return type:
- species_energies(model, cutoff, batch_size=32, device=None)[source]#
The energies
(S,)of the species frommodel(graph)["energy"], in batches of structures (differentiable in the model’s parameters when gradients are enabled).
- loss(species_energy, huber_delta=0.0)[source]#
reaction_energy_loss()of these reactions for the species energies(S,).