pub struct SequentialSampler { /* private fields */ }Expand description
連番順(シャッフルなし)でバッチ添字を供給する(PyTorch
SequentialSampler 相当。イシュー #2182)。グローバル RNG を
一切消費しない。
Implementations§
Source§impl SequentialSampler
impl SequentialSampler
Sourcepub fn new(
len: usize,
batch_size: usize,
drop_last: bool,
) -> Result<SequentialSampler, DataError>
pub fn new( len: usize, batch_size: usize, drop_last: bool, ) -> Result<SequentialSampler, DataError>
len はデータセットのサンプル総数。batch_size == 0 は
DataError::ZeroBatchSize。
Trait Implementations§
Source§impl Debug for SequentialSampler
impl Debug for SequentialSampler
Source§impl Sampler for SequentialSampler
impl Sampler for SequentialSampler
Source§fn next_batch(&mut self) -> Vec<usize>
fn next_batch(&mut self) -> Vec<usize>
次バッチの添字列。空の
Vec は epoch 終了の番兵。Source§fn num_batches(&self) -> Option<usize>
fn num_batches(&self) -> Option<usize>
1 epoch あたりのバッチ数(既知なら
Some。既定は None)。
SamplerBatches::size_hint・HookedBatches::size_hint は
本メソッドの戻り値(epoch 全体の静的総数)と、各イテレータ自身が
追跡する「これまでに yield した数」の差分で残数を計算する
(レビュー指摘: イシュー #2182 review・PR #2310 codex-review
P2 是正)。カスタム Sampler 実装が進捗追跡用の別メソッドを
override する必要はなく、本メソッドだけを実装すれば途中経過・
epoch 終了後のどちらでも Iterator::size_hint の「残り要素数」
契約(下限の非過大申告)を満たす。Auto Trait Implementations§
impl Freeze for SequentialSampler
impl RefUnwindSafe for SequentialSampler
impl Send for SequentialSampler
impl Sync for SequentialSampler
impl Unpin for SequentialSampler
impl UnsafeUnpin for SequentialSampler
impl UnwindSafe for SequentialSampler
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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