2024年6月6日发(作者:竹浩涆)
32 # now load the picked numpy arrays
33 if :
34 _data = []
35 _labels = []
36 for fentry in _list:
37 f = fentry[0]
38 file = (, _folder, f)
39 fo = open(file, 'rb')
40 if n_info[0] == 2:
41 entry = (fo)
42 else:
43 entry = (fo, encoding='latin1')
44 _(entry['data'])
45 if 'labels' in entry:
46 _labels += entry['labels']
47 else:
48 _labels += entry['fine_labels']
49 ()
50
51 _data = enate(_data)
52 _data = _e((50000, 3, 32, 32))
53 _data = _ose((0, 2, 3, 1)) # convert to HWC
54 else:
55 f = _list[0][0]
56 file = (, _folder, f)
57 fo = open(file, 'rb')
58 if n_info[0] == 2:
59 entry = (fo)
60 else:
61 entry = (fo, encoding='latin1')
62 _data = entry['data']
63 if 'labels' in entry:
64 _labels = entry['labels']
65 else:
66 _labels = entry['fine_labels']
67 ()
68 _data = _e((10000, 3, 32, 32))
69 _data = _ose((0, 2, 3, 1)) # convert to HWC
70
71 def __getitem__(self, index):
72 """
73 Args:
74 index (int): Index
75
76 Returns:
77 tuple: (image, target) where target is index of the target class.
78 """
79 if :
80 img, target = _data[index], _labels[index]
81 else:
82 img, target = _data[index], _labels[index]
83
84 # doing this so that it is consistent with all other datasets
85 # to return a PIL Image
86 img = ray(img)
87
88 if orm is not None:
89 img = orm(img)
90
91 if _transform is not None:
92 target = _transform(target)
93
94 return img, target
2024年6月6日发(作者:竹浩涆)
32 # now load the picked numpy arrays
33 if :
34 _data = []
35 _labels = []
36 for fentry in _list:
37 f = fentry[0]
38 file = (, _folder, f)
39 fo = open(file, 'rb')
40 if n_info[0] == 2:
41 entry = (fo)
42 else:
43 entry = (fo, encoding='latin1')
44 _(entry['data'])
45 if 'labels' in entry:
46 _labels += entry['labels']
47 else:
48 _labels += entry['fine_labels']
49 ()
50
51 _data = enate(_data)
52 _data = _e((50000, 3, 32, 32))
53 _data = _ose((0, 2, 3, 1)) # convert to HWC
54 else:
55 f = _list[0][0]
56 file = (, _folder, f)
57 fo = open(file, 'rb')
58 if n_info[0] == 2:
59 entry = (fo)
60 else:
61 entry = (fo, encoding='latin1')
62 _data = entry['data']
63 if 'labels' in entry:
64 _labels = entry['labels']
65 else:
66 _labels = entry['fine_labels']
67 ()
68 _data = _e((10000, 3, 32, 32))
69 _data = _ose((0, 2, 3, 1)) # convert to HWC
70
71 def __getitem__(self, index):
72 """
73 Args:
74 index (int): Index
75
76 Returns:
77 tuple: (image, target) where target is index of the target class.
78 """
79 if :
80 img, target = _data[index], _labels[index]
81 else:
82 img, target = _data[index], _labels[index]
83
84 # doing this so that it is consistent with all other datasets
85 # to return a PIL Image
86 img = ray(img)
87
88 if orm is not None:
89 img = orm(img)
90
91 if _transform is not None:
92 target = _transform(target)
93
94 return img, target