mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 17:34:49 +08:00
[pre-commit.ci] pre-commit autoupdate (#12398)
updates: - [github.com/astral-sh/ruff-pre-commit: v0.4.10 → v0.5.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.4.10...v0.5.0) - [github.com/pre-commit/mirrors-mypy: v1.10.0 → v1.10.1](https://github.com/pre-commit/mirrors-mypy/compare/v1.10.0...v1.10.1) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
![66853113+pre-commit-ci[bot]@users.noreply.github.com](/assets/img/avatar_default.png)
committed by
GitHub

parent
f3f32ae3ca
commit
fc33c50593
@ -61,9 +61,8 @@ def _extract_images(f):
|
||||
with gzip.GzipFile(fileobj=f) as bytestream:
|
||||
magic = _read32(bytestream)
|
||||
if magic != 2051:
|
||||
raise ValueError(
|
||||
"Invalid magic number %d in MNIST image file: %s" % (magic, f.name)
|
||||
)
|
||||
msg = f"Invalid magic number {magic} in MNIST image file: {f.name}"
|
||||
raise ValueError(msg)
|
||||
num_images = _read32(bytestream)
|
||||
rows = _read32(bytestream)
|
||||
cols = _read32(bytestream)
|
||||
@ -102,9 +101,8 @@ def _extract_labels(f, one_hot=False, num_classes=10):
|
||||
with gzip.GzipFile(fileobj=f) as bytestream:
|
||||
magic = _read32(bytestream)
|
||||
if magic != 2049:
|
||||
raise ValueError(
|
||||
"Invalid magic number %d in MNIST label file: %s" % (magic, f.name)
|
||||
)
|
||||
msg = f"Invalid magic number {magic} in MNIST label file: {f.name}"
|
||||
raise ValueError(msg)
|
||||
num_items = _read32(bytestream)
|
||||
buf = bytestream.read(num_items)
|
||||
labels = np.frombuffer(buf, dtype=np.uint8)
|
||||
|
Reference in New Issue
Block a user