Struct burn::data::dataset::InMemDataset
pub struct InMemDataset<I> { /* private fields */ }
Expand description
Dataset where all items are stored in ram.
Implementations§
§impl<I> InMemDataset<I>
impl<I> InMemDataset<I>
pub fn new(items: Vec<I>) -> InMemDataset<I>
pub fn new(items: Vec<I>) -> InMemDataset<I>
Creates a new in memory dataset from the given items.
§impl<I> InMemDataset<I>where
I: Clone + DeserializeOwned,
impl<I> InMemDataset<I>where
I: Clone + DeserializeOwned,
pub fn from_dataset(dataset: &impl Dataset<I>) -> InMemDataset<I>
pub fn from_dataset(dataset: &impl Dataset<I>) -> InMemDataset<I>
Create from a dataset. All items are loaded in memory.
pub fn from_json_rows<P>(path: P) -> Result<InMemDataset<I>, Error>
pub fn from_json_rows<P>(path: P) -> Result<InMemDataset<I>, Error>
Create from a json rows file (one json per line).
pub fn from_csv<P>(
path: P,
builder: &ReaderBuilder,
) -> Result<InMemDataset<I>, Error>
pub fn from_csv<P>( path: P, builder: &ReaderBuilder, ) -> Result<InMemDataset<I>, Error>
Create from a csv file.
The provided csv::ReaderBuilder
can be configured to fit your csv format.
The supported field types are: String, integer, float, and bool.
See:
Trait Implementations§
§impl<I> Dataset<I> for InMemDataset<I>
impl<I> Dataset<I> for InMemDataset<I>
Auto Trait Implementations§
impl<I> Freeze for InMemDataset<I>
impl<I> RefUnwindSafe for InMemDataset<I>where
I: RefUnwindSafe,
impl<I> Send for InMemDataset<I>where
I: Send,
impl<I> Sync for InMemDataset<I>where
I: Sync,
impl<I> Unpin for InMemDataset<I>where
I: Unpin,
impl<I> UnwindSafe for InMemDataset<I>where
I: UnwindSafe,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<I, T> Windows<I> for Twhere
T: Dataset<I>,
impl<I, T> Windows<I> for Twhere
T: Dataset<I>,
§fn windows(&self, size: usize) -> WindowsIterator<'_, I> ⓘ
fn windows(&self, size: usize) -> WindowsIterator<'_, I> ⓘ
Is empty if the Dataset
is shorter than size
.
§Panics
Panics if size
is 0.
§Examples
use crate::burn_dataset::{
transform::{Windows, WindowsDataset},
Dataset, InMemDataset,
};
let items = [1, 2, 3, 4].to_vec();
let dataset = InMemDataset::new(items.clone());
for window in dataset.windows(2) {
// do sth with window
}