pub struct GPTDataLoader { /* private fields */ }
Expand description
A type for building a Batcher
over a GPTDataset
with specified params.
Implementations§
Source§impl GPTDataLoader
impl GPTDataLoader
Sourcepub fn new(
dataset: GPTDatasetV1,
batch_size: usize,
shuffle: bool,
drop_last: bool,
) -> Self
pub fn new( dataset: GPTDatasetV1, batch_size: usize, shuffle: bool, drop_last: bool, ) -> Self
Creates a new GPTDataLoader.
use llms_from_scratch_rs::listings::ch02::{GPTDatasetV1, GPTDataLoader};
use tiktoken_rs::get_bpe_from_model;
let txt = "In the heart of the city";
let tokenizer = tiktoken_rs::get_bpe_from_model("gpt2").unwrap();
let max_length = 3_usize;
let stride = 1_usize;
let dataset = GPTDatasetV1::new(txt, tokenizer, max_length, stride);
let batch_size = 2_usize;
let shuffle = false;
let drop_last = false;
let data_loader = GPTDataLoader::new(dataset, batch_size, shuffle, drop_last);
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl DataLoader for GPTDataLoader
impl DataLoader for GPTDataLoader
Source§fn batcher(&self) -> GPTDataBatcher
fn batcher(&self) -> GPTDataBatcher
Returns a GPTDataBatcher
that itself provides batches over the
associated dataset.
type Batcher = Batcher<IterResult2<GPTDatasetIter>>
Auto Trait Implementations§
impl Freeze for GPTDataLoader
impl RefUnwindSafe for GPTDataLoader
impl !Send for GPTDataLoader
impl !Sync for GPTDataLoader
impl Unpin for GPTDataLoader
impl UnwindSafe for GPTDataLoader
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
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> ⓘ
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