Skip to content

Rollover behaviour and returned id of .add() Question #23

Answered by ymd-h
Sebastian-Griesbach asked this question in Q&A
Discussion options

You must be logged in to vote

@Sebastian-Griesbach
Thank you for your feedback.

Could you give us an example code?

As far as I tried with cpprb v10.6.4 on Google Colab, replay buffer works correctly.

Single step addition

import cpprb
rb = cpprb.ReplayBuffer(3, {"a": {}})

for _ in range(5):
    print(rb.add(a=2))

# 0
# 1
# 2
# 0
# 1

Batch addition

import cpprb
rb = cpprb.ReplayBuffer(3, {"a": {}})

for _ in range(5):
    print(rb.add(a=[2, 2]))

# 0
# 2
# 1
# 0
# 2

More details

import cpprb
rb = cpprb.ReplayBuffer(3, {"a": {}})

for i in range(5):
    p_idx = rb.add(a=[i, i+1])
    n_idx = rb.get_next_index()
    buf = rb.get_all_transitions()
    print((p_idx, n_idx, buf))

# (0, 2, {'a': array([[0.], [1.]], dtype=f…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Sebastian-Griesbach
Comment options

@ymd-h
Comment options

@Sebastian-Griesbach
Comment options

@Sebastian-Griesbach
Comment options

@ymd-h
Comment options

Answer selected by Sebastian-Griesbach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants