Skip to content

Commit b44abb8

Browse files
danijarVijay Vasudevan
authored and
Vijay Vasudevan
committed
Fix dataset encoding in MNIST example for Python 3
1 parent 97bde2c commit b44abb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tensorflow/examples/tutorials/mnist/input_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def _read32(bytestream):
5050
def extract_images(filename):
5151
"""Extract the images into a 4D uint8 numpy array [index, y, x, depth]."""
5252
print('Extracting', filename)
53-
with gzip.open(filename) as bytestream:
53+
with tf.gfile.Open(filename, 'rb') as f, gzip.GzipFile(fileobj=f) as bytestream:
5454
magic = _read32(bytestream)
5555
if magic != 2051:
5656
raise ValueError(
@@ -77,7 +77,7 @@ def dense_to_one_hot(labels_dense, num_classes=10):
7777
def extract_labels(filename, one_hot=False):
7878
"""Extract the labels into a 1D uint8 numpy array [index]."""
7979
print('Extracting', filename)
80-
with gzip.open(filename) as bytestream:
80+
with tf.gfile.Open(filename, 'rb') as f, gzip.GzipFile(fileobj=f) as bytestream:
8181
magic = _read32(bytestream)
8282
if magic != 2049:
8383
raise ValueError(

0 commit comments

Comments
 (0)