pub struct ReplayBatch {
pub observations: Vec<f32>,
pub actions: Vec<i64>,
pub rewards: Vec<f32>,
pub next_observations: Vec<f32>,
pub dones: Vec<bool>,
pub obs_dim: usize,
}Expand description
One minibatch sampled from the replay buffer.
All fields are CPU-side primitive vectors; convert to Burn tensors
via ReplayBatch::to_burn_tensors when handing them to the trainer.
Fields§
§observations: Vec<f32>Flattened current observations, shape [batch_size * obs_dim].
actions: Vec<i64>Actions taken, length batch_size.
rewards: Vec<f32>Rewards received, length batch_size.
next_observations: Vec<f32>Flattened next observations, shape [batch_size * obs_dim].
dones: Vec<bool>Episode-end mask, length batch_size. true means the transition
terminated the episode (so the TD target drops the bootstrap term).
obs_dim: usizeLength of one observation slice (so to_tensors can reshape).
Implementations§
Source§impl ReplayBatch
impl ReplayBatch
Sourcepub fn to_burn_tensors<B: Backend>(
&self,
device: &B::Device,
) -> ReplayBurnTensors<B>
pub fn to_burn_tensors<B: Backend>( &self, device: &B::Device, ) -> ReplayBurnTensors<B>
Stack the batch into Burn tensors on device.
Returns a named ReplayBurnTensors struct so trainers can
pattern-match named fields rather than positional tuple elements.
Shapes (all on device):
observations:[batch, obs_dim],f32actions:[batch],i64(BurnIntkind)rewards:[batch],f32next_observations:[batch, obs_dim],f32dones:[batch],f32(0.0 / 1.0; the TD-target formula(1 - done)consumes it directly as a float mask).
Trait Implementations§
Source§impl Clone for ReplayBatch
impl Clone for ReplayBatch
Source§fn clone(&self) -> ReplayBatch
fn clone(&self) -> ReplayBatch
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ReplayBatch
impl RefUnwindSafe for ReplayBatch
impl Send for ReplayBatch
impl Sync for ReplayBatch
impl Unpin for ReplayBatch
impl UnsafeUnpin for ReplayBatch
impl UnwindSafe for ReplayBatch
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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