-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Saving and loading replay buffer with HDF5 #261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Saving and loading replay buffer with HDF5 #261
Conversation
Codecov Report
@@ Coverage Diff @@
## master #261 +/- ##
==========================================
+ Coverage 94.40% 94.54% +0.13%
==========================================
Files 41 41
Lines 2611 2677 +66
==========================================
+ Hits 2465 2531 +66
Misses 146 146
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.swp file should not add to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are formatting issues.
Co-authored-by: n+e <trinkle23897@qq.com>
Co-authored-by: n+e <trinkle23897@qq.com>
Co-authored-by: n+e <trinkle23897@qq.com>
Co-authored-by: n+e <trinkle23897@qq.com>
…nshou into save_load_replay_buffer
Seems it cannot work well with cuda tensor. (github action doesn't have cuda environment :( $ python3 test/base/test_buffer.py
Traceback (most recent call last):
File "test/base/test_buffer.py", line 327, in <module>
test_hdf5()
File "test/base/test_buffer.py", line 300, in test_hdf5
vbuf.save(path)
File "/home/trinkle/github/tianshou-new/tianshou/data/buffer.py", line 409, in save
self._copy_to_hdf5(k, v, f)
File "/home/trinkle/github/tianshou-new/tianshou/data/buffer.py", line 370, in _copy_to_hdf5
grp.create_dataset(k, data=v.numpy())
TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. update: resolved |
Also, could you please add this feature description in the docstring of |
It looks perfect to me ! Ready to be merged :) Very good job @nicoguertler |
Great! Thank you @duburcqa and @Trinkle23897 for your help and advice! There is still some room for improvement. For example, there is no custom conversion for the |
Yes, but the current implementation can be extended very easily, which is great ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation!
Looks good to me now @Trinkle23897 |
As mentioned in thu-ml#260, this pull request is about an implementation of saving and loading the replay buffer with HDF5.
As mentioned in #260, this pull request is about an implementation of saving and loading the replay buffer with HDF5.
I added a test of this feature but its probably not exhaustive. Feedback on whether saving and loading works for real projects is welcome.