-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdata.py
More file actions
29 lines (22 loc) · 759 Bytes
/
data.py
File metadata and controls
29 lines (22 loc) · 759 Bytes
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
import torch
import torchvision
import numpy as np
import random
def reprod_init():
np.random.seed(0)
random.seed(0)
torch.manual_seed(0)
torch.cuda.manual_seed(0)
torch.backends.cudnn.deterministic = True
def data_prep():
mnist_train = torchvision.datasets.MNIST('./', download=True, train=True)
mnist_test = torchvision.datasets.MNIST('./', download=True, train=False)
x_train = mnist_train.train_data
y_train = mnist_train.train_labels
x_test = mnist_test.test_data
y_test = mnist_test.test_labels
x_train = x_train.float()
x_test = x_test.float()
x_train = x_train.reshape(-1, 784)
x_test = x_test.reshape(-1, 784)
return x_train, y_train, x_test, y_test