Permalink
Browse files

simplified reader

  • Loading branch information...
kashif committed Sep 4, 2017
1 parent b85ead6 commit 5e11b3c4bde07165d3cd48bd2e156650ae837c12
Showing with 5 additions and 6 deletions.
  1. +5 −6 utils/mnist_reader.py
View
@@ -1,6 +1,5 @@
def load_mnist(path, kind='train'):
import os
import struct
import gzip
import numpy as np
@@ -13,11 +12,11 @@ def load_mnist(path, kind='train'):
% kind)
with gzip.open(labels_path, 'rb') as lbpath:
struct.unpack('>II', lbpath.read(8))
labels = np.frombuffer(lbpath.read(), dtype=np.uint8)
labels = np.frombuffer(lbpath.read(), dtype=np.uint8,
offset=8)
with gzip.open(images_path, 'rb') as imgpath:
struct.unpack(">IIII", imgpath.read(16))
images = np.frombuffer(imgpath.read(), dtype=np.uint8).reshape(len(labels), 784)
images = np.frombuffer(imgpath.read(), dtype=np.uint8,
offset=16).reshape(len(labels), 784)
return images, labels
return images, labels

0 comments on commit 5e11b3c

Please sign in to comment.