def images(filename):
    fp = open(filename,'rb')
    chunk = fp.read(16)
    magicnumber, length, numrows, numcols = struct.unpack('>iiii', chunk)
    assert magicnumber in (2049, 2051), ("Not an MNIST file: %i" % magicnumber)
    imagesize = numrows * numcols
    for _ in range(length):
        imagestring = fp.read(imagesize)
        image = struct.unpack('B' * imagesize, imagestring)
        yield scipy.array(image)
dataset/ETHPy150Open pybrain/pybrain/pybrain/tools/datasets/mnist.py/images/original