ufldl_tutorial
ufldl_tutorial copied to clipboard
ValueError
when I run the train.py,I get the following error
images = images.reshape((num_images[0], num_rows[0] * num_cols[0])).transpose()
Traceback (most recent call last):
File "/home/snow/Documents/study/ufldl_tutorial/train.py", line 42, in
#####code begin with open(filename, "rb") as f: magic = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_images = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_rows = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
num_cols = np.fromfile(f, dtype=np.dtype('>i4'), count=1)
#num_images = 60000
#num_rows = 28
#num_cols = 28
images = np.fromfile(f, dtype=np.ubyte)
images = images.reshape((num_images[0], num_rows[0] * num_cols[0])).transpose()
images = images.astype(np.float64) / 255
f.close()
#####code end
I google the http://yann.lecun.com/exdb/mnist/ find the value: 0004 32 bit integer 60000 number of images 0008 32 bit integer 28 number of rows 0012 32 bit integer 28 number of columns
by calculating the value, I find 282860000 larger than the 9912422,that makes me so confused, How can I correct the code?
It's easy to solve, when you download these file(.gz), you must decompressed they at first. I meet the error, for these words in the http://yann.lecun.com/exdb/mnist/
please note that your browser may uncompress these files without telling you. If the files you downloaded have a larger size than the above, they have been uncompressed by your browser. Simply rename them to remove the .gz extension.