writers
#
Output functions for run-fit.
Functions:
-
open_writer–Open a TensorBoard writer.
-
write_scatter–Predict and save energies/forces to HDF5.
-
report–Report training progress for Levenberg-Marquardt optimizer.
-
write_metrics–Write metrics to TensorBoard and output file.
-
get_potential_summary–Get string summary of a potential's parameters.
-
get_potential_comparison–Get string comparison of two potentials.
open_writer
#
Open a TensorBoard writer.
write_scatter
#
write_scatter(
dataset: Dataset,
force_field: TensorForceField,
topology_in: TensorTopology,
device: device,
filename: PathLike,
) -> tuple[float, float, float, float]
Predict and save energies/forces to HDF5.
Source code in presto/writers.py
report
#
report(
step: int,
x: Tensor,
loss: Tensor,
gradient: Tensor,
hessian: Tensor,
step_quality: float,
accept_step: bool,
trainable: Trainable,
topologies: list[TensorTopology],
datasets_train: list[Dataset],
datasets_test: list[Dataset],
initial_parameters: Tensor,
regularisation_target: Literal["initial", "zero"],
metrics_file: PathLike,
experiment_dir: Path,
) -> None
Report training progress for Levenberg-Marquardt optimizer.
This function computes training and test losses using the same loss computation as train_adam (via compute_overall_loss_and_grad) to ensure consistent metrics reporting.
Args: step: Current optimization step. x: Current trainable parameters. loss: Loss value from the optimizer (not used, we recompute for consistency). gradient: Gradient tensor (not used in reporting). hessian: Hessian tensor (not used in reporting). step_quality: Quality measure of the step (not used in reporting). accept_step: Whether the step was accepted (not used in reporting). trainable: The trainable object containing the force field. topologies: List of topologies for all molecules. datasets_train: List of training datasets for all molecules. datasets_test: List of test datasets for all molecules. initial_parameters: Initial parameters for regularization. regularisation_target: Regularization target ('initial' or 'zero'). metrics_file: Path to the metrics output file. experiment_dir: Path to the TensorBoard experiment directory.
Source code in presto/writers.py
write_metrics
#
write_metrics(
i: int,
loss_train: LossRecord,
loss_test: LossRecord,
writer: SummaryWriter,
outfile: TextIO,
) -> None
Write metrics to TensorBoard and output file.
Source code in presto/writers.py
get_potential_summary
#
Get string summary of a potential's parameters.
Source code in presto/writers.py
get_potential_comparison
#
Get string comparison of two potentials.