1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
//! # Incin Data
//!
//! Provides dataset and dataloader abstractions for the Incin framework.
//! Handles batching, shuffling, and data transformation pipelines.
//!
//! ## Examples
//!
//! A `Dataset` supplies items by index; a `Collate` can turn a batch into the
//! model's input type; a `DataLoader` joins the two and yields typed `Result`
//! values so worker failures cannot look like end-of-data. Use
//! `DataLoader::builder` for the default scalar, tuple, and tensor batching
//! policy.
//!
//! ```rust
//! use incin_data::{Collate, DataLoader, Dataset};
//!
//! struct Squares;
//!
//! impl Dataset for Squares {
//! type Item = u32;
//!
//! fn len(&self) -> usize {
//! 100
//! }
//!
//! fn get(&self, index: usize) -> Result<Option<Self::Item>, incin_data::DataError> {
//! Ok(u32::try_from(index).ok().filter(|_| index < self.len()).map(|i| i * i))
//! }
//! }
//!
//! struct IntoBatch;
//!
//! impl Collate<u32> for IntoBatch {
//! type Output = Vec<u32>;
//!
//! fn collate(&self, batch: Vec<u32>) -> incin_data::BatchResult<Self::Output> {
//! Ok(batch)
//! }
//! }
//!
//! // Batches of 32, shuffled. Loading happens on worker threads; iterating
//! // borrows the loader, so the same one can be iterated each epoch.
//! let loader = DataLoader::new(Squares, IntoBatch, 32).unwrap().with_shuffle(true);
//!
//! let batches: Vec<Vec<u32>> = (&loader).into_iter().collect::<Result<_, _>>().unwrap();
//! assert_eq!(batches.len(), 4); // 100 items is three full batches and a short one
//! assert_eq!(batches.iter().map(Vec::len).sum::<usize>(), 100);
//! ```
extern crate alloc;
/// Dataset.
/// Downloader.
/// Hub.
/// Loader.
/// Transforms and data processing pipelines.
/// Vision.
pub use Dataset;
pub use Downloader;
pub use ;
pub use ;
/// Prelude.