shraddha
shraddha

Reputation: 33

How to unpack mnist dataset?

I want to unpack a pkl file from a MNIST dataset. I have used this code to do that:

import cPickle, gzip, numpy
# Load the dataset
f = gzip.open(’mnist.pkl.gz’, ’rb’)
train_set, valid_set, test_set = cPickle.load(f)
f.close()

But I am getting this error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/gzip.py", line 34, in open
return GzipFile(filename, mode, compresslevel)
File "/usr/lib/python2.7/gzip.py", line 94, in __init__
fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
IOError: [Errno 2] No such file or directory: 'mnist.pkl.gz'

The mnist.pkl.gz file is on the desktop. How to specify the path in the code?

Upvotes: 3

Views: 2702

Answers (1)

Noxeus
Noxeus

Reputation: 577

Put /home/<username>/Desktop/ in front of mnist.pkl.gz or launch it with the terminal working directory being the Desktop.

Upvotes: 1

Related Questions