Skip to content

Commit dffb2d1

Browse files
authored
Merge pull request #16 from adamlerer/python3_fixes
python 3 fixes
2 parents e4c811c + 3ebdb4d commit dffb2d1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

torchvision/datasets/cifar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ def __init__(self, root, train=True, transform=None, target_transform=None, down
4949
f = fentry[0]
5050
file = os.path.join(root, self.base_folder, f)
5151
fo = open(file, 'rb')
52-
entry = pickle.load(fo)
52+
if sys.version_info[0] == 2:
53+
entry = pickle.load(fo)
54+
else:
55+
entry = pickle.load(fo, encoding='latin1')
5356
self.train_data.append(entry['data'])
5457
if 'labels' in entry:
5558
self.train_labels += entry['labels']

torchvision/datasets/lsun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(self, db_path, classes='train',
7171
for c in classes:
7272
c_short = c.split('_')
7373
c_short.pop(len(c_short) - 1)
74-
c_short = string.join(c_short, '_')
74+
c_short = '_'.join(c_short)
7575
if c_short not in categories:
7676
raise(ValueError('Unknown LSUN class: ' + c_short + '.'\
7777
'Options are: ' + str(categories)))

torchvision/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def make_grid(tensor, nrow=8, padding=2):
2828
for x in range(xmaps):
2929
if k >= nmaps:
3030
break
31-
grid.narrow(1, y*height+1+padding/2,height-padding)\
32-
.narrow(2, x*width+1+padding/2, width-padding)\
31+
grid.narrow(1, y*height+1+padding//2,height-padding)\
32+
.narrow(2, x*width+1+padding//2, width-padding)\
3333
.copy_(tensor[k])
3434
k = k + 1
3535
return grid

0 commit comments

Comments
 (0)