- class netket.experimental.logging.HDF5Log[source]#
HDF5 Logger, that can be passed with keyword argument logger to Monte Carlo drivers in order to serialize the output data of the simulation.
The logger has support for scalar numbers, NumPy/JAX arrays, and netket.stats.Stats objects. These are stored as individual groups within a HDF5 file, under the main group data/:
scalars are stored as a group with one dataset values of shape
(n_steps,)containing the logged values,
arrays are stored in the same way, but with values having shape
netket.stats.Stats are stored as a group containing each field
(Mean, Variance, etc...)as a separate dataset.
Importantly, each group has a dataset
iters, which tracks the iteration number of the logged quantity.
If the model state is serialized, then it is serialized as a dataset in the group variational_state/. The target of the serialization is the parameters PyTree of the variational state (stored in the group variational_state/parameters), and the rest of the variational state variables (stored in the group variational_state/model_state)
Data can be deserialized by calling
f = h5py.File(filename, 'r')and inspecting the datasets as a dictionary, i.e.
The API of this logger is covered by our Semantic Versioning API guarantees. However, the structure of the logged files is not, and might change in the future while we iterate on this logger. If you think that we could improve the output format of this logger, please open an issue on the NetKet repository and let us know.
- __init__(path, mode='write', save_params=True, save_params_every=1)[source]#
Construct a HDF5 Logger.
str) – the name of the output files before the extension
str) – Specify the behaviour in case the file already exists at this path. Options are - [w]rite: (default) overwrites file if it already exists; - [x] or fail: fails if file already exists;
bool) – bool flag indicating whether variables of the variational state should be serialized at some interval
int) – every how many iterations should machine parameters be flushed to file