Commit dffb2d13 authored by Soumith Chintala's avatar Soumith Chintala Committed by GitHub
Browse files

Merge pull request #16 from adamlerer/python3_fixes

python 3 fixes
parents e4c811c9 3ebdb4df
...@@ -49,7 +49,10 @@ class CIFAR10(data.Dataset): ...@@ -49,7 +49,10 @@ class CIFAR10(data.Dataset):
f = fentry[0] f = fentry[0]
file = os.path.join(root, self.base_folder, f) file = os.path.join(root, self.base_folder, f)
fo = open(file, 'rb') fo = open(file, 'rb')
entry = pickle.load(fo) if sys.version_info[0] == 2:
entry = pickle.load(fo)
else:
entry = pickle.load(fo, encoding='latin1')
self.train_data.append(entry['data']) self.train_data.append(entry['data'])
if 'labels' in entry: if 'labels' in entry:
self.train_labels += entry['labels'] self.train_labels += entry['labels']
......
...@@ -71,7 +71,7 @@ class LSUN(data.Dataset): ...@@ -71,7 +71,7 @@ class LSUN(data.Dataset):
for c in classes: for c in classes:
c_short = c.split('_') c_short = c.split('_')
c_short.pop(len(c_short) - 1) c_short.pop(len(c_short) - 1)
c_short = string.join(c_short, '_') c_short = '_'.join(c_short)
if c_short not in categories: if c_short not in categories:
raise(ValueError('Unknown LSUN class: ' + c_short + '.'\ raise(ValueError('Unknown LSUN class: ' + c_short + '.'\
'Options are: ' + str(categories))) 'Options are: ' + str(categories)))
......
...@@ -28,8 +28,8 @@ def make_grid(tensor, nrow=8, padding=2): ...@@ -28,8 +28,8 @@ def make_grid(tensor, nrow=8, padding=2):
for x in range(xmaps): for x in range(xmaps):
if k >= nmaps: if k >= nmaps:
break break
grid.narrow(1, y*height+1+padding/2,height-padding)\ grid.narrow(1, y*height+1+padding//2,height-padding)\
.narrow(2, x*width+1+padding/2, width-padding)\ .narrow(2, x*width+1+padding//2, width-padding)\
.copy_(tensor[k]) .copy_(tensor[k])
k = k + 1 k = k + 1
return grid return grid
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment