This is the second commit of 6 commits mentioned in #274, which features minor refactor of ReplayBuffer and adding two new ReplayBuffer classes called CachedReplayBuffer and ReplayBufferManager. You can check #274 for more detail. 1. Add ReplayBufferManager (handle a list of buffers) and CachedReplayBuffer; 2. Make sure the reserved keys cannot be edited by methods like `buffer.done = xxx`; 3. Add `set_batch` method for manually choosing the batch the ReplayBuffer wants to handle; 4. Add `sample_index` method, same as `sample` but only return index instead of both index and batch data; 5. Add `prev` (one-step previous transition index), `next` (one-step next transition index) and `unfinished_index` (the last modified index whose done==False); 6. Separate `alloc_fn` method for allocating new memory for `self._meta` when a new `(key, value)` pair comes in; 7. Move buffer's documentation to `docs/tutorials/concepts.rst`. Co-authored-by: n+e <trinkle23897@gmail.com>
21 lines
589 B
Python
21 lines
589 B
Python
from tianshou.data.batch import Batch
|
|
from tianshou.data.utils.converter import to_numpy, to_torch, to_torch_as
|
|
from tianshou.data.utils.segtree import SegmentTree
|
|
from tianshou.data.buffer import ReplayBuffer, ListReplayBuffer, \
|
|
PrioritizedReplayBuffer, ReplayBufferManager, CachedReplayBuffer
|
|
from tianshou.data.collector import Collector
|
|
|
|
__all__ = [
|
|
"Batch",
|
|
"to_numpy",
|
|
"to_torch",
|
|
"to_torch_as",
|
|
"SegmentTree",
|
|
"ReplayBuffer",
|
|
"ListReplayBuffer",
|
|
"PrioritizedReplayBuffer",
|
|
"ReplayBufferManager",
|
|
"CachedReplayBuffer",
|
|
"Collector",
|
|
]
|