8.10.5. Logger¶
-
class
Logger
(data_sets: Dict[str, scm.params.core.dataset.DataSet], interface: scm.params.parameterinterfaces.base.BaseParameters, losses: Dict[str, scm.params.core.lossfunctions.Loss], path: Optional[Union[str, pathlib.Path]] = None, group_by: Optional[Tuple[str]] = None, iteration_digits: int = 6, sort_stats_by: str = 'contribution', general_log_interval: int = 10, parameters_log_interval: int = 500, history_log_interval: int = 500, flush_log_interval: int = 10)¶ Logger class used to save function evaluations to disk. Single instance is used for all logging from all optimizers.
Logs and saves the following data produced during an Optimization to disk for every Data Set provided:
best/*: Same as latest/* but for the iteration with the lowest loss function.
history/ : Same as latest/* but stored every history iterations.
initial/*: Same as latest/* but for the initial parameter settings.
latest/active_parameters.txt: iteration and list of current parameter values.
latest/data_set_predictions.yaml: file in DataSet yaml format that can be loaded with a DataSetEvaluator.
latest/engine.txt: Engine settings block for AMS.
latest/evaluation.txt: Current evaluation number.
latest/loss.txt: The loss function value.
latest/parameter_interface.yaml: Parameters in yaml format.
latest/pes_predictions/*.txt: Predictions for all entries with the
pes
extractor.latest/scatter_plots/*.txt: Current predictions per extractor or grouped as defined by the group_by attribute.
latest/stats.txt: Current MAE and RMSE per extractor or grouped as defined by the group_by attribute.
running_active_parameters.txt: The values of the (active) parameters, stored every ‘parameters’ iterations.
running_loss.txt: iteration and loss function value. Plottable with
params plot
.running_stats.txt: mae and rmse per extractor or grouped as defined by the group_by attribute.
Depending on the parameter interface, also:
latest/lj_parameters.txt: For Lennard-Jones optimizations, contains the LJ parameters
latest/ffield.ff: For ReaxFF optimizations, contains the parameters in ffield format
latest/xtb_files: For GFN1-xTB optimizations, contains the parameters in a format that can be read by AMS
The files are stored in a directory called dataset_name_results, e.g. training_set_results.
Note
It is possible to turn off the logging of a particular type by setting the associated
*_log_interval parameter=0
- Parameters
- data_setsDict[str, DataSet]
Dictionary of data set names to
DataSet
instances.- interfaceBaseParameters
Parameter interface used during the optimization. Note that a copy of the interface is made by the logger so that the provided interface and logger interface are no longer the same python object.
- lossesDict[str, Loss]
Dictionary of data set names to
Loss
instances.- path :str OR Path, optional
Path to root directory in which all files will be logged. Defaults to the current working directory.
- group_bytuple of strings
A tuple in the same format as accepted by DataSetEvaluator.group_by().
Examples
group_by=('Extractor', 'Expression') # default group_by=('Group', 'SubGroup') # requires that the dataset entries have Group and SubGroup metadata
- iteration_digitsint
Number of digits to print the iteration number to file names and latest/evaluation.txt, running_loss.txt, and running_stats.txt.
Example: iteration_digits == 6 will print the first iteration as 000001
Example: iteration_digits == None will print the first iteration as 1
- sort_stats_bystr
Sort the latest/stats.txt and related files.
‘contribution’: sort by contribution to loss function value
‘rmse’: sort by rmse
‘mae’: sort by mae
None: do not sort (use the same order as in the original DataSet)
- general_log_intervalint
Interval between writes to stdout, running_loss and running_stats and all latest/ and best/ files.
- parameters_log_intervalint
Interval between writes to running_active_parameters.txt
- history_log_intervalint
Interval of copies from ‘latest’ to ‘history’
- flush_log_intervalint
How often to flush the running_* files