class netket.logging.JsonLog[source]#

Bases: RuntimeLog

This logger serializes expectation values and other log data to a JSON file and can save the latest model parameters in MessagePack encoding to a separate file.

It can be passed with keyword argument out to Monte Carlo drivers in order to serialize the output data of the simulation.

This logger inherits from netket.logging.RuntimeLog, so it maintains the dictionary of all logged quantities in memory, which can be accessed through the attribute data.

If the model state is serialized, then it can be de-serialized using the msgpack protocol of flax. For more information on how to de-serialize the output, see here. The target of the serialization is the variational state itself.

Data is serialized to json as several nested dictionaries. You can deserialize by simply calling json.load(open(filename)). Logged expectation values will be captured inside histories objects, so they will have a subfield iter with the iterations at which that quantity has been computed, then Mean and others. Complex numbers are logged as dictionaries {'real':list, 'imag':list}.

Inheritance diagram of netket.logging.JsonLog
__init__(output_prefix, mode='write', save_params_every=50, write_every=50, save_params=True, autoflush_cost=0.005)[source]#

Construct a Json Logger.

  • output_prefix (str) – the name of the output files before the extension

  • save_params_every (int) – every how many iterations should machine parameters be flushed to file

  • write_every (int) – every how many iterations should data be flushed to file

  • mode (str) – Specify the behaviour in case the file already exists at this output_prefix. Options are - [w]rite: (default) overwrites file if it already exists; - [x] or fail: fails if file already exists;

  • save_params (bool) – bool flag indicating whether variables of the variational state should be serialized at some interval. The output file is overwritten every time variables are saved again.

  • autoflush_cost (float) – Maximum fraction of runtime that can be dedicated to serializing data. Defaults to 0.005 (0.5 per cent)


The dictionary of logged data.

__call__(step, item, variational_state=None)[source]#

Logs at a given integer step a dictionary of data, optionally specifying a variational state to encode additional data.

  • step – monotonically increasing integer representing the row in the database corresponding to this log entry;

  • item – Any dictionary of data to be logged;

  • variational_state – optional variational state from which additional data might be extracted.


Writes to file the content of this logger.


variational_state – optionally also writes the parameters of the machine.


Serialize the content of data to a file.

If the file already exists, it is overwritten.


path (Union[str, Path, IO]) – The path of the output file. It must be a valid path.