[Optimization] Replay Buffers shouldn't use copy when using np.array
See original GitHub issueRelated to #49
We call np.ndarray(x).copy()
. This is unnecessary because np.array has the argument “copy” which is True by default.
https://numpy.org/doc/stable/reference/generated/numpy.array.html
import numpy as np
x = [1,2,3,4,5]
x1 = np.array(x)
x is x1
# False
x2 = np.array(x1)
x2 is x1
# False
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How does this Python memory optimization work?
ndarray data, and not actually storing each copy of the individual array within itself. import numpy as np a = np.ones((2,3)) b =...
Read more >Replay Buffers — rlpyt documentation - Read the Docs
Use of namedarraytuples makes it straightforward to write data of arbitrary ... If modifying a replay buffer, it might be easier to first...
Read more >4.5. Understanding the internals of NumPy to avoid ...
In this recipe, we will see how to avoid unnecessary array copies in order to save memory. In that respect, we will need...
Read more >Deep Q-Network (DQN)-II - Towards Data Science
This technique is called replay buffer or experience buffer. ... individual NumPy arrays with batch data in PyTorch tensors and copies them ...
Read more >Part I: On-policy learning and SARSA (3 points)
The policy we're gonna use is epsilon-greedy policy, where agent takes optimal action with probability $(1-\epsilon)$, otherwise samples action at random.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, lets make another PR for optimizations like this 👍 . Lets wait until agent performance has been matched so things do not crisscross to badly.
Pardon, it was a general suggestion, not related specifically to this issue.