pub struct SequenceReplayBuffer { /* private fields */ }Expand description
Replay buffer that samples contiguous sequences of transitions.
Wraps a ReplayBuffer for storage and an EpisodeTracker for
episode-aware sequence sampling. Sequences never cross episode
boundaries.
Implementations§
Source§impl SequenceReplayBuffer
impl SequenceReplayBuffer
Sourcepub fn new(capacity: usize, obs_dim: usize, act_dim: usize) -> Self
pub fn new(capacity: usize, obs_dim: usize, act_dim: usize) -> Self
Create a new sequence replay buffer with given capacity and dimensions.
Sourcepub fn push_slices(
&mut self,
obs: &[f32],
next_obs: &[f32],
action: &[f32],
reward: f32,
terminated: bool,
truncated: bool,
) -> Result<(), RloxError>
pub fn push_slices( &mut self, obs: &[f32], next_obs: &[f32], action: &[f32], reward: f32, terminated: bool, truncated: bool, ) -> Result<(), RloxError>
Push a single transition, notifying the episode tracker.
Sourcepub fn sample_sequences(
&self,
batch_size: usize,
seq_len: usize,
seed: u64,
) -> Result<SequenceBatch, RloxError>
pub fn sample_sequences( &self, batch_size: usize, seq_len: usize, seed: u64, ) -> Result<SequenceBatch, RloxError>
Sample batch_size sequences of seq_len consecutive transitions.
Each sequence is guaranteed to be within a single episode.
Sourcepub fn sample(
&self,
batch_size: usize,
seed: u64,
) -> Result<SampledBatch, RloxError>
pub fn sample( &self, batch_size: usize, seed: u64, ) -> Result<SampledBatch, RloxError>
Delegate to inner buffer for standard i.i.d. sampling.
Sourcepub fn num_complete_episodes(&self) -> usize
pub fn num_complete_episodes(&self) -> usize
Number of complete episodes currently tracked.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SequenceReplayBuffer
impl RefUnwindSafe for SequenceReplayBuffer
impl Send for SequenceReplayBuffer
impl Sync for SequenceReplayBuffer
impl Unpin for SequenceReplayBuffer
impl UnwindSafe for SequenceReplayBuffer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more