Skip to content

File read error. #9

@xiehuanyi

Description

@xiehuanyi

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions