dlsyscourse / hw0

14 stars 23 forks source link

File read error. #9

Open xiehuanyi opened 1 year ago

xiehuanyi commented 1 year ago

I used numpy.fromfile api to read given data, but got wrong data. code are as follow:

import numpy as np
a = np.fromfile('data/train-images-idx3-ubyte', dtype=np.float32)
b = np.fromfile('data/train-labels-idx1-ubyte', dtype=np.uint8)
l_a = a.shape[0]
l_b = b.shape[0]
print(f"{l_a // (28*28)} images found")
print(f"{l_b} labels found")

and the output is this:

15000 images found
60008 labels found

It seems not all right. What's wrong with this solution and what can I do to run it properly?

xiehuanyi commented 1 year ago

and I unzipped the data by the way