pub struct RolloutBatch {
pub observations: Vec<f32>,
pub actions: Vec<i64>,
pub old_log_probs: Vec<f32>,
pub old_values: Vec<f32>,
pub advantages: Vec<f32>,
pub returns: Vec<f32>,
}Expand description
Batch of rollout data for training
Contains flattened tensors suitable for neural network training.
All arrays have shape [batch_size].
Fields§
§observations: Vec<f32>Flattened observations [batch_size, obs_dim]
actions: Vec<i64>Actions taken [batch_size]
old_log_probs: Vec<f32>Old log probabilities [batch_size]
old_values: Vec<f32>Old value estimates [batch_size]
advantages: Vec<f32>Computed advantages [batch_size]
returns: Vec<f32>Computed returns [batch_size]
Implementations§
Source§impl RolloutBatch
impl RolloutBatch
Sourcepub fn from_buffer(buffer: &RolloutBuffer) -> Self
pub fn from_buffer(buffer: &RolloutBuffer) -> Self
Create a new batch from rollout buffer
Iterates the full [num_steps, num_envs] capacity. If the buffer
was only partially filled, the unwritten tail surfaces as
zero-initialized rows. Use Self::from_buffer_partial (or
super::RolloutBuffer::get_filled_batch) when the caller
knows the fill count.
Sourcepub fn from_buffer_partial(buffer: &RolloutBuffer, valid_steps: usize) -> Self
pub fn from_buffer_partial(buffer: &RolloutBuffer, valid_steps: usize) -> Self
Create a new batch from the first valid_steps rows of the buffer.
Rows in valid_steps..num_steps (the unfilled tail of a partial
rollout) are skipped, preventing zero-padded rows from
contaminating PPO gradients.
§Panics
Panics if valid_steps > buffer.num_steps.
Sourcepub fn to_burn_tensors<B: Backend>(
&self,
device: &B::Device,
) -> RolloutBurnTensors<B>
pub fn to_burn_tensors<B: Backend>( &self, device: &B::Device, ) -> RolloutBurnTensors<B>
Construct the full set of training tensors from this batch in a
Construct the full set of training tensors as Burn tensors on
device.
Returns a named RolloutBurnTensors bundle so trainers can
pattern-match named fields rather than positional tuple elements.
Shapes (all on device):
observations:[batch, obs_dim],f32actions:[batch],i64(BurnIntkind)old_log_probs:[batch],f32old_values:[batch],f32advantages:[batch],f32returns:[batch],f32
Empty batches still produce well-formed [0, obs_dim] /
[0] tensors. The obs_dim is derived from
Self::obs_shape (which returns 0 for an empty batch), so
the observation tensor for the empty case is shaped [0, 0].
Trait Implementations§
Source§impl Clone for RolloutBatch
impl Clone for RolloutBatch
Source§fn clone(&self) -> RolloutBatch
fn clone(&self) -> RolloutBatch
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 RolloutBatch
impl RefUnwindSafe for RolloutBatch
impl Send for RolloutBatch
impl Sync for RolloutBatch
impl Unpin for RolloutBatch
impl UnsafeUnpin for RolloutBatch
impl UnwindSafe for RolloutBatch
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