energy
#
Train against relative energies and forces.
Classes:
-
Entry–Represents a set of reference energies and forces.
Functions:
-
create_dataset–Create a dataset from a list of existing entries.
-
create_dataset_from_generator–Create a dataset from a generator function, avoiding loading all entries into
-
extract_smiles–Return a list of unique SMILES strings in the dataset.
-
predict–Predict the relative energies [kcal/mol] and forces [kcal/mol/Å] of a dataset.
Entry
#
Bases: TypedDict
Represents a set of reference energies and forces.
Attributes:
-
smiles(str) –The indexed SMILES description of the molecule the energies and forces were
-
coords(Tensor) –The coordinates [Å] the energies and forces were evaluated at with
-
energy(Tensor) –The reference energies [kcal/mol] with
shape=(n_confs,). -
forces(Tensor) –The reference forces [kcal/mol/Å] with
shape=(n_confs, n_particles, 3).
smiles
instance-attribute
#
The indexed SMILES description of the molecule the energies and forces were computed for.
coords
instance-attribute
#
The coordinates [Å] the energies and forces were evaluated at with
shape=(n_confs, n_particles, 3).
forces
instance-attribute
#
The reference forces [kcal/mol/Å] with shape=(n_confs, n_particles, 3).
create_dataset
#
create_dataset(entries: list[Entry]) -> Dataset
Create a dataset from a list of existing entries.
Parameters:
-
entries(list[Entry]) –The entries to create the dataset from.
Returns:
-
Dataset–The created dataset.
Source code in descent/targets/energy.py
create_dataset_from_generator
#
create_dataset_from_generator(
gen_fn: Callable[[], Iterator[Entry]],
) -> Dataset
Create a dataset from a generator function, avoiding loading all entries into memory at once.
Parameters:
-
gen_fn(Callable[[], Iterator[Entry]]) –A callable that returns an iterator of entries. It will be called by the HuggingFace datasets library and must be re-iterable (i.e. each call to
gen_fn()should produce a fresh iterator).
Returns:
-
Dataset–The created dataset.
Source code in descent/targets/energy.py
extract_smiles
#
Return a list of unique SMILES strings in the dataset.
Parameters:
-
dataset(Dataset) –The dataset to extract the SMILES strings from.
Returns:
-
list[str]–The list of unique SMILES strings.
Source code in descent/targets/energy.py
predict
#
predict(
dataset: Dataset,
force_field: TensorForceField,
topologies: dict[str, TensorTopology],
reference: Literal["mean", "min"] = "mean",
normalize: bool = True,
) -> tuple[Tensor, Tensor, Tensor, Tensor]
Predict the relative energies [kcal/mol] and forces [kcal/mol/Å] of a dataset.
Parameters:
-
dataset(Dataset) –The dataset to predict the energies and forces of.
-
force_field(TensorForceField) –The force field to use to predict the energies and forces.
-
topologies(dict[str, TensorTopology]) –The topologies of the molecules in the dataset. Each key should be a fully indexed SMILES string.
-
reference(Literal['mean', 'min'], default:'mean') –The reference energy to compute the relative energies with respect to. This should be either the "mean" energy of all conformers, or the energy of the conformer with the lowest reference energy ("min").
-
normalize(bool, default:True) –Whether to scale the relative energies by
1/sqrt(n_confs_i)and the forces by1/sqrt(n_confs_i * n_atoms_per_conf_i * 3)This is useful when wanting to compute the MSE per entry.
Returns:
-
tuple[Tensor, Tensor, Tensor, Tensor]–The predicted and reference relative energies [kcal/mol] with
shape=(n_confs,), and predicted and reference forces [kcal/mol/Å] withshape=(n_confs * n_atoms_per_conf, 3).
Source code in descent/targets/energy.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |