Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset and DataLoader #18

Merged
merged 5 commits into from
Nov 9, 2023
Merged

Dataset and DataLoader #18

merged 5 commits into from
Nov 9, 2023

Conversation

fszewczyk
Copy link
Owner

Implement an abstraction of a Dataset and a DataLoader that can perform batching.

Usage

// This is our XOR dataset. It maps from Vec32 to Vec32
Dataset<Vec32, Vec32> data;
data.addSample(Vec32::of(0, 0), Vec32::of(0));
data.addSample(Vec32::of(0, 1), Vec32::of(1));
data.addSample(Vec32::of(1, 0), Vec32::of(1));
data.addSample(Vec32::of(1, 1), Vec32::of(0));

// The is the data loader, it will take care of batching
size_t batchSize = 2;
bool shuffle = true;
DataLoader loader(data, batchSize, shuffle);

// DataLoader deals internally with generating batches
for (const auto &[in, out] : loader){
    // in and out are of type std::vector<Vec32>
    mlp -> forward(in);
    (...)
}

@fszewczyk fszewczyk merged commit ef545a1 into master Nov 9, 2023
3 checks passed
@fszewczyk fszewczyk deleted the dataset branch November 9, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant