open error in raise OSError('Not agzipped file(%r)'%magic)gzip

Asked 2 years ago, Updated 2 years ago, 93 views

sample code in the book Deep Learning from scratch

$python mnist.py

When I ran it, I got the following error in the gzip part.
The execution environment is Anaoconda3(python3.5), windows7.

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "C:\Users\user_name\Anaconda3\Lib\gzip.py", line 274, in read
    return self._buffer.read(size)
  File "C:\Users\user_name\Anaconda3\Lib\gzip.py", line 461, in read
    if not self._read_gzip_header():
  File "C:\Users\user_name\Anaconda3\Lib\gzip.py", line 409, in_read_gzip_header
    raise OSError('Not agzipped file(%r)'%magic)
OSError: Not aggregated file (b'<!')

The code (excerpt) for the part that appears to be related to the error is the ## part below.

def_load_label(file_name):
    file_path=dataset_dir+"/"+file_name    
    print("Converting" + file_name + "to NumPy Array...")
    with gzip.open(file_path, 'rb') asf:
            labels=np.frombuffer(f.read(), np.uint8, offset=8)###
    print("Done")
    return labels  

How should I deal with this?

python python3 gzip

2022-09-29 21:22

1 Answers

Perhaps the reason for the error was that the downloaded file was corrupted.

gz I deleted the file and ran mnist.py again, and it worked.

This post was posted as a community wiki based on @sketch's comments.


2022-09-29 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.