File size: 949 Bytes
d625688
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import torch
import torchvision
import torchvision.transforms as transforms


import numpy as np


def get_datasets():
    
    transform = transforms.Compose(
        [transforms.ToTensor(),
         transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

    batch_size = 1

    trainset = torchvision.datasets.CIFAR10(root='./data', train=True,
                                            download=True, transform=transform)
    trainloader = torch.utils.data.DataLoader(trainset, batch_size=batch_size,
                                              shuffle=True, num_workers=1)

    validset = torchvision.datasets.CIFAR10(root='./data', train=False,
                                           download=True, transform=transform)
    validloader = torch.utils.data.DataLoader(validset, batch_size=batch_size,
                                             shuffle=False, num_workers=1)

    return trainset, trainloader, validset, validloader