Kaixhin / ACER

Actor-critic with experience replay
MIT License
251 stars 46 forks source link

Simple features added to save the data. #8

Closed random-user-x closed 6 years ago

random-user-x commented 6 years ago

Added a few features to save the data in an efficient manner.

random-user-x commented 6 years ago

I have added the changes. Please let me know if this works. Thanks

random-user-x commented 6 years ago

@Kaixhin Please let me know how you want the csv results to be saved. I think I do not get what you meant by using pickle.dump or torch.save. I guess saving a file in csv format should make it convenient for the users to view the results. Please let me know what you meant in your previous comment.

Kaixhin commented 6 years ago

I would like the results to be saved as a Python dictionary of arrays, like so:

results_dict = {'t': [], 'reward': [], 'avg_steps': [], 'time': []}
...
results_dict['reward'].append(reward)

There are two ways to save the dictionary then. pickle would be pure Python and hence easy to read in and manipulate further with Python:

with open('results.pck', 'wb') as f:
  pickle.dump(results_dict, f)

Alternatively you could use torch.save(results_dict, 'results.pth'), which is simpler as it doesn't require opening a file handle, but does make the data less portable. So I would suggest pickle. CSV is a nice format, but it's not a clear winner over JSON or HDF5, for example. So considering that users are using Python already, keeping results as Python objects makes it trivial to continue analysis/visualisation in Python, and converting to a more portable file format isn't difficult if needed.

random-user-x commented 6 years ago

Hello Kaixhin,

I have added the pickle support as you mentioned in your previous comment. I would like to inform you that I have not removed the csv support from the software. Many people including me love to have a look at the csv file via MS excel or the libre office. Do you mind if we keep both?

Please let me know your views.

Kaixhin commented 6 years ago

Thanks for adding the pickled results file. Since the additional overhead for CSV is relatively small then I don't mind keeping it.

random-user-x commented 6 years ago

@Kaixhin , please add this PR to the repo. :)