pub struct OfflineDatasetBuffer { /* private fields */ }Expand description
Read-only offline dataset buffer.
Implementations§
Source§impl OfflineDatasetBuffer
impl OfflineDatasetBuffer
Sourcepub fn from_arrays(
obs: Vec<f32>,
next_obs: Vec<f32>,
actions: Vec<f32>,
rewards: Vec<f32>,
terminated: Vec<u8>,
truncated: Vec<u8>,
obs_dim: usize,
act_dim: usize,
) -> Result<Self, RloxError>
pub fn from_arrays( obs: Vec<f32>, next_obs: Vec<f32>, actions: Vec<f32>, rewards: Vec<f32>, terminated: Vec<u8>, truncated: Vec<u8>, obs_dim: usize, act_dim: usize, ) -> Result<Self, RloxError>
Create from flat arrays.
Arrays must be row-major: obs has length n * obs_dim, etc.
pub fn is_empty(&self) -> bool
Sourcepub fn n_episodes(&self) -> usize
pub fn n_episodes(&self) -> usize
Number of episodes in the dataset.
pub fn obs_dim(&self) -> usize
pub fn act_dim(&self) -> usize
Sourcepub fn compute_normalization(&mut self)
pub fn compute_normalization(&mut self)
Compute and cache normalization statistics.
Sourcepub fn sample(&self, batch_size: usize, seed: u64) -> OfflineBatch
pub fn sample(&self, batch_size: usize, seed: u64) -> OfflineBatch
Sample i.i.d. transitions uniformly.
Sourcepub fn sample_trajectories(
&self,
batch_size: usize,
seq_len: usize,
seed: u64,
) -> TrajectoryBatch
pub fn sample_trajectories( &self, batch_size: usize, seq_len: usize, seed: u64, ) -> TrajectoryBatch
Sample contiguous trajectory subsequences.
Each sample is a contiguous window of seq_len transitions from a
single episode. If the episode is shorter than seq_len, the sequence
is right-padded with zeros and the mask indicates valid positions.
Sourcepub fn stats(&self) -> DatasetStats
pub fn stats(&self) -> DatasetStats
Get dataset statistics.
Auto Trait Implementations§
impl Freeze for OfflineDatasetBuffer
impl RefUnwindSafe for OfflineDatasetBuffer
impl Send for OfflineDatasetBuffer
impl Sync for OfflineDatasetBuffer
impl Unpin for OfflineDatasetBuffer
impl UnwindSafe for OfflineDatasetBuffer
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