-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdata_loader_batch.py
31 lines (28 loc) · 952 Bytes
/
data_loader_batch.py
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
import torch
from torchvision import datasets, transforms
class DataLoader:
@staticmethod
def get_train_data(batch_size):
return torch.utils.data.DataLoader(
datasets.MNIST(
'../data',
train=True,
download=True,
transform=transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))
])),
batch_size=batch_size,
shuffle=True)
@staticmethod
def get_test_data(test_batch_size):
return torch.utils.data.DataLoader(
datasets.MNIST(
'../data',
train=False,
transform=transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1307,), (0.3081,))
])),
batch_size=test_batch_size,
shuffle=True)