pub struct Dataset {
pub inputs: Tensor,
pub targets: Tensor,
}
Fields§
§inputs: Tensor
§targets: Tensor
Implementations§
source§impl Dataset
impl Dataset
sourcepub fn new(inputs: Tensor, targets: Tensor) -> Self
pub fn new(inputs: Tensor, targets: Tensor) -> Self
Create a new dataset from the given input and target tensors. The number of samples in the input and target tensors must be the same.
§Examples
let inputs = tensor![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
let targets = tensor![[0.0], [1.0], [0.0]];
let dataset = Dataset::new(inputs, targets);
sourcepub fn batches(&self, batch_size: usize) -> Vec<(Tensor, Tensor)>
pub fn batches(&self, batch_size: usize) -> Vec<(Tensor, Tensor)>
Create batches of input and target tensors with the given batch size. The last batch may be smaller if the number of samples is not divisible by the batch size.
§Examples
let inputs = tensor![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
let targets = tensor![[0.0], [1.0], [0.0]];
let dataset = Dataset::new(inputs, targets);
let batches = dataset.batches(2);
sourcepub fn batch(&self, start: usize, end: usize) -> (Tensor, Tensor)
pub fn batch(&self, start: usize, end: usize) -> (Tensor, Tensor)
Get a batch of input and target tensors [start..end].
§Examples
let inputs = tensor![[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]];
let targets = tensor![[0.0], [1.0], [0.0]];
let dataset = Dataset::new(inputs, targets);
let (input_batch, target_batch) = dataset.batch(0, 2);
Auto Trait Implementations§
impl Freeze for Dataset
impl RefUnwindSafe for Dataset
impl Send for Dataset
impl Sync for Dataset
impl Unpin for Dataset
impl UnwindSafe for Dataset
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