pub struct PrioritizedBatch {
pub observations: Vec<f32>,
pub actions: Vec<i64>,
pub rewards: Vec<f32>,
pub next_observations: Vec<f32>,
pub dones: Vec<bool>,
pub is_weights: Vec<f32>,
pub indices: Vec<usize>,
pub obs_dim: usize,
}Expand description
One minibatch sampled from a PrioritizedReplayBuffer.
All fields are CPU-side primitive vectors; convert to Burn tensors
via PrioritizedBatch::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.
is_weights: Vec<f32>Per-sample importance-sampling weights, length batch_size,
normalized so max(weights) == 1.0.
indices: Vec<usize>Sum-tree leaf indices for the sampled transitions, length
batch_size. Pass these back into
PrioritizedReplayBuffer::update_priorities alongside the new
TD errors.
obs_dim: usizeLength of one observation slice.
Implementations§
Source§impl PrioritizedBatch
impl PrioritizedBatch
Sourcepub fn to_burn_tensors<B: Backend>(
&self,
device: &B::Device,
) -> PrioritizedBurnTensors<B>
pub fn to_burn_tensors<B: Backend>( &self, device: &B::Device, ) -> PrioritizedBurnTensors<B>
Stack the batch into Burn tensors on device.
Returns a named PrioritizedBurnTensors struct so the DQN
trainer can grab fields by name. Includes the importance-sampling
weights that the uniform super::ReplayBatch does not carry.
Shapes (all on device):
observations:[batch, obs_dim],f32actions:[batch],i64rewards:[batch],f32next_observations:[batch, obs_dim],f32dones:[batch],f32(0.0 / 1.0)is_weights:[batch],f32
Note: indices is not a tensor — leaf-index round-trips back
into PrioritizedReplayBuffer::update_priorities as a host
&[usize], so it stays on self.
Trait Implementations§
Source§impl Clone for PrioritizedBatch
impl Clone for PrioritizedBatch
Source§fn clone(&self) -> PrioritizedBatch
fn clone(&self) -> PrioritizedBatch
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PrioritizedBatch
impl RefUnwindSafe for PrioritizedBatch
impl Send for PrioritizedBatch
impl Sync for PrioritizedBatch
impl Unpin for PrioritizedBatch
impl UnsafeUnpin for PrioritizedBatch
impl UnwindSafe for PrioritizedBatch
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
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>
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>
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