Reputation: 105
I got the following error when I tried to import mnist:
from sklearn.datasets import fetch_mldata
import mnist
data_path = "../dataset"
mnist = fetch_mldata('MNIST original', data_home=data_path)
#mnist = MNIST('../dataset/MNIST')
x_train, y_train = mnist.load_training() #60000 samples
x_test, y_test = mnist.load_testing() #10000 samples
X_train = np.asarray(x_train).astype(np.float32)
y_train = np.asarray(y_train).astype(np.int32)
X_test = np.asarray(x_test).astype(np.float32)
y_test = np.asarray(y_test).astype(np.int32)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-8-5cbf011c3576> in <module>
1 import mnist
2
----> 3 mnist = MNIST('../dataset/MNIST')
4 x_train, y_train = mnist.load_training() #60000 samples
5 x_test, y_test = mnist.load_testing() #10000 samples
NameError: name 'MNIST' is not defined
ImportError Traceback (most recent call last)
<ipython-input-3-5e6e64b70463> in <module>
----> 1 from sklearn.datasets import fetch_mldata
2 import mnist
3
4 data_path = "../dataset"
5 mnist = fetch_mldata('MNIST original', data_home=data_path)
ImportError: cannot import name 'fetch_mldata' from 'sklearn.datasets' (C:\Users\Angelus\anaconda3\lib\site-packages\sklearn\datasets\__init__.py)
I used Anaconda to install mist. I tried to uninstall it and install it again but I still receive the same error message
Thank you
Upvotes: 0
Views: 6573
Reputation: 2962
This is not how you use Python, import and mnist, your syntax is wrong. From the documentation:
from mnist import MNIST
mndata = MNIST('./dir_with_mnist_data_files')
And please don't use mnist
as a variable name because it's a package name. Already.
Upvotes: 1