netket.logging.StateLog#
- class netket.logging.StateLog[source]#
Bases:
AbstractLog
A logger which serializes the variables of the variational state during a run.
The data is saved either to a directory or tar archive in a sequence of files named [0.mpack, 1.mpack, …] where the filename is incremented every time the logger is called. The tar file inside is not flushed to disk (closed) until this object is deleted or python is shut down.
- Inheritance
- __init__(output_prefix, mode='write', save_every=1, tar=False)[source]#
Initialize the
StateLogger
.- Parameters:
output_prefix (
str
) – the name of the output file before the extension (if tar=True) or of the output folder.save_every (
int
) – every how many iterations the variables should be saved. (default 1)mode (
Union
[Literal
['write'
],Literal
['append'
],Literal
['fail'
],Literal
['x'
],Literal
['w'
],Literal
['a'
]]) – Specify the behaviour in case the file already exists at this output_prefix. Options are `[w]rite`: (default) overwrites file/delete the folder if it already exists; `[a]ppend`: appends to the file/folder if it exists, otherwise creates a new file; `[x]` or `fail`: fails if file/folder already exists;tar (
bool
) – if True creates a tar archive instead of a folder.
- Methods
- __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.
- Parameters:
step (
int
) – monotonically increasing integer representing the row in the database corresponding to this log entry;item (
dict
[str
,Any
]) – Any dictionary of data to be logged;variational_state (
VariationalState
|None
) – optional variational state from which additional data might be extracted.