-
Notifications
You must be signed in to change notification settings - Fork 33
Simple usage example? (eg. MNIST) #381
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
Comments
+1 , that would be really cool ! |
Any updates on this? |
Maybe it helps: from dataclasses import dataclass
import grain.python as pygrain
@dataclass
class MyDataset:
data: list
def __len__(self):
return len(self.data)
def __getitem__(self, idx: int):
return self.data[idx]
data_source = MyDataset(list(range(6)))
sampler = pygrain.IndexSampler(
len(data_source),
shuffle=True,
seed=2,
shard_options=pygrain.NoSharding(),
num_epochs=3,
)
batch_size = 3
dl = pygrain.DataLoader(
data_source=data_source, sampler=sampler, operations=[pygrain.Batch(batch_size)]
)
for sample in dl:
print(sample)
"""Prints:
[0 4 1]
[2 3 5]
[4 3 0]
[1 2 5]
[5 0 4]
[3 2 1]
""" |
There is another example of |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, thanks for making this! Is there a simple training example, perhaps with MNIST or another small dataset?
The text was updated successfully, but these errors were encountered: