While executing the Lesson 5- SGB-MNIST example I am getting an error on the sentence below.
with gzip.open(path/‘mnist.pkl.gz’, ‘rb’) as f:
((x_train, y_train), (x_valid, y_valid), _) = pickle.load(f, encoding=‘latin-1’)
Error thrown is : OSError: Not a gzipped file (b’\x80\x02’).
The file does exist in the folder but it seems that the gzip.open expects a magic header of b’\037\213’.
If you are using Mac OS X, the system automatically unzips the gz file and give you mnist.pkl after download. Did you somehow change the name back into mnist.pkl.gz?
Below is what I did in OS X and it worked fine for me:
with open(path/'mnist.pkl', 'rb') as f:
((x_train, y_train), (x_valid, y_valid), _) = pickle.load(f, encoding='latin-1')
/anaconda3/lib/python3.6/_compression.py in readinto(self, b)
66 def readinto(self, b):
67 with memoryview(b) as view, view.cast(“B”) as byte_view:
—> 68 data = self.read(len(byte_view))
69 byte_view[:len(data)] = data
70 return len(data)
/anaconda3/lib/python3.6/gzip.py in read(self, size)
461 # jump to the next member, if there is one.
462 self._init_read()
–> 463 if not self._read_gzip_header():
464 self._size = self._pos
465 return b""
/anaconda3/lib/python3.6/gzip.py in _read_gzip_header(self)
409
410 if magic != b’\037\213’:
–> 411 raise OSError(‘Not a gzipped file (%r)’ % magic)
412
413 (method, flag,