Skip to main content

IterableDataset

Trait IterableDataset 

Source
pub trait IterableDataset {
    type Sample;

    // Required method
    fn iter_samples(
        &self,
    ) -> Box<dyn Iterator<Item = Result<Self::Sample, DataError>> + '_>;
}
Expand description

1 epoch 分のサンプル列を先頭から返す iterable-style データセット。

super::Dataset を継承・実装しない(len()/添字アクセスを持たない)。 要素を Result とするのは、供給元の失敗を panic ではなく型付きエラー (DataError::IterableStream 等)で伝えるため。

Required Associated Types§

Source

type Sample

1 サンプルの型(Tensor<T>、または特徴量とラベルのタプル等)。

Required Methods§

Source

fn iter_samples( &self, ) -> Box<dyn Iterator<Item = Result<Self::Sample, DataError>> + '_>

サンプル列を先頭から返す(PyTorch __iter__ 相当)。呼ぶたびに 新しいストリームを返す(IterableDataLoader::iter が epoch ごとに 1 回呼ぶ)。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§