`stack_compress` is not working with more than one value
When I try to use stack_compress with more than one value I get the following error (I use the latest version installed with pip and python 3.8)
Traceback (most recent call last):
File "test_rb2.py", line 6, in <module>
prb = PrioritizedReplayBuffer(buffer_size, stack_compress=["obs", "next_obs"],
File "cpprb/PyReplayBuffer.pyx", line 986, in cpprb.PyReplayBuffer.ReplayBuffer.__cinit__
File "cpprb/PyReplayBuffer.pyx", line 498, in cpprb.PyReplayBuffer.dict2buffer
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Below is a minimal example to try
import numpy as np
from cpprb import PrioritizedReplayBuffer
buffer_size = 256
prb = PrioritizedReplayBuffer(buffer_size, stack_compress=["obs", "next_obs"],
env_dict={"obs": {"shape": (32,32,4)},
"act": {"shape": 3},
"rew": {},
"next_obs": {"shape": (32,32,4)},
"done": {}},
alpha=0.5)
for i in range(1000):
prb.add(obs=np.zeros((32,32,4)),
act=np.ones(3),
rew=0.5,
next_obs=np.zeros((32,32,4)),
done=0)
batch_size = 32
s = prb.sample(batch_size,beta=0.5)
indexes = s["indexes"]
weights = s["weights"]
# train
# ...
new_priorities = np.ones_like(weights)
prb.update_priorities(indexes,new_priorities)