Reputation: 77
I'm trying to load the MNIST dataset using the MNIST library that you can find here https://github.com/sorki/python-mnist. The problem comes with me not even being able to load it.
from mnist import MNIST
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
mndata = MNIST('.')
images, labels = mndata.load_training()
This gives me the error of
FileNotFoundError: [Errno 2] No such file or directory: '.\\train-labels-idx1-ubyte'
Which I'm not really sure why it's occurring, as the exact file is located under that exact name in the folder I'm working in with this python file. I've also tried giving the exact path instead of just '.' but it isn't working.
If it is of any help I'm using Windows 10 and Python 3. Thanks a lot in advance!
Upvotes: 0
Views: 2788
Reputation: 77
Figured it out. It seems when I was using Winrar to unpack the .gz files from the MNIST dataset it was changing how the files were named even though it seemed to follow the naming convention that MNIST wanted. So instead of extracting them I just kept them as .gz files and used the mndata.gz = True so that MNIST could handle the extracting of the files itself.
Upvotes: -1
Reputation: 186
You can import MNIST directly from Keras by using:
from keras.datasets import mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()
Also other libraries have this dataset built in and I personally find it easier to use these methods than downloading the dataset to my computer, it is especially helpful when you work on multiple computers or online environments like Google Collaboratory.
Upvotes: 1