New logging
Created by: PhilipVinc
This is my proposal for the new logging system, going alongside nk3
Things I disliked:
- The output format previously was a json file with a single dict with a key,
output
, with a list of data logged at every iteration, and another keyiterations
with the iteration numbers. - To deserialise this format one has to determine the objects logged inside every iterations (some might not always be logged, such as objservables), initialise some accumulators, iterate through every element in
output
and add the right object to the right accumulator. Also, one has then to reconstruct the iteration numbers for objects that are not logged at every iteration
{`Output`: [
{ 'Energy': {'Mean': 0.3, 'Variance':....} ,
{ 'Energy': {'Mean': 0.2, 'Variance':....} ,
{ 'Energy': {'Mean': 0.1, 'Variance':....} ,
...
],
`Iters`:[1,2,3...]
}
Changes:
- The new output format is still a json file, but now it's simply a dict of time series :
{ 'Energy': {
'Mean': {'iters':[1,2,3...] , 'values':[0.3, 0.2,0.1....]
'Variance': {'iters':[1,2,3...] , 'values':[0.01, 0.02,0.01....]
'Sigma': {'iters':[1,2,3...] , 'values':[0.01, 0.02,0.01....]
}
}
this makes it much easier to de-serialize, as simply deserialising with json gives a structure that can be plotted with:
import Matplotlib.pyplot as plt
data = json.load(open("test.log"))
plt.plot(data['Energy']['Mean']['iters'], data['Energy']['Mean']['values']
internally, during runtime, all logged quantities are stored in a tree of History
objects (time-series), that store both the iteration and the values at every iteration. They are then natively serialised to json...