pub trait BatchBase {
// Required methods
fn new(capacity: usize) -> Self;
fn push(&mut self, ix: usize, data: Self);
fn sample(&self, ixs: &Vec<usize>) -> Self;
}
Expand description
A trait defining basic batch operations.
This trait provides fundamental operations for efficiently managing batches of observations and actions.
§Type Parameters
Self
- The batch type, representing batches of observations or actions.
§Examples
ⓘ
struct TensorBatch {
data: Vec<f32>,
shape: Vec<usize>,
}
impl BatchBase for TensorBatch {
fn new(capacity: usize) -> Self {
Self {
data: Vec::with_capacity(capacity),
shape: vec![],
}
}
fn push(&mut self, ix: usize, data: Self) {
// Data addition logic
}
fn sample(&self, ixs: &Vec<usize>) -> Self {
// Sampling logic
}
}
Required Methods§
Sourcefn new(capacity: usize) -> Self
fn new(capacity: usize) -> Self
Creates a new batch with the specified capacity.
§Arguments
capacity
- Initial capacity of the batch
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.