MCPcopy Create free account
hub / github.com/M-Nauta/ProtoTree / get_dataloaders

Function get_dataloaders

util/data.py:30–56  ·  view source on GitHub ↗

Get data loaders

(args: argparse.Namespace)

Source from the content-addressed store, hash-verified

28 raise Exception(f'Could not load data set "{args.dataset}"!')
29
30def get_dataloaders(args: argparse.Namespace):
31 """
32 Get data loaders
33 """
34 # Obtain the dataset
35 trainset, projectset, testset, classes, shape = get_data(args)
36 c, w, h = shape
37 # Determine if GPU should be used
38 cuda = not args.disable_cuda and torch.cuda.is_available()
39 trainloader = torch.utils.data.DataLoader(trainset,
40 batch_size=args.batch_size,
41 shuffle=True,
42 pin_memory=cuda
43 )
44 projectloader = torch.utils.data.DataLoader(projectset,
45 # batch_size=args.batch_size,
46 batch_size=int(args.batch_size/4), #make batch size smaller to prevent out of memory errors during projection
47 shuffle=False,
48 pin_memory=cuda
49 )
50 testloader = torch.utils.data.DataLoader(testset,
51 batch_size=args.batch_size,
52 shuffle=False,
53 pin_memory=cuda
54 )
55 print("Num classes (k) = ", len(classes), flush=True)
56 return trainloader, projectloader, testloader, classes, c
57
58
59def get_birds(augment: bool, train_dir:str, project_dir: str, test_dir:str, img_size = 224):

Callers 3

run_ensembleFunction · 0.90
explain_localFunction · 0.90
run_treeFunction · 0.90

Calls 1

get_dataFunction · 0.85

Tested by

no test coverage detected