Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python, keras, load_data function extremely slow

I was trying to load the dataset mnist/cifar10 from keras, but it takes like forever to download it(the downloading speed gradually slows down, in the beginning it was quick, but then it gets slower and slower),e.g. still not be able to download the dataset in several hours. Here is my code:

from keras.datasets import mnist
from matplotlib import pyplot
from scipy.misc import toimage

(X_train, Y_train),(X_test,Y_test) = mnist.load_data()

for i in range(0.9):
   pyplot.subplot(330+1+i)
   pyplot.imshow(toimage(X_train[i]))
pyplot.show()

I have looked on the web, people usually don't encounter these problems, normally the dataset can be downloaded in several minutes. I have tried reinstalling python and other packages, but it did not help. Can anyone help me please?

like image 607
Octavius Avatar asked Oct 12 '25 07:10

Octavius


1 Answers

I had the same issue. The problem is the IDLE not the code, the IDLE runs slower for every line printed. Instead run the python code in a terminal, power-shell or command prompt. Then it should run in about 5 seconds, the file is only 52 MB.

like image 182
David McDermott Avatar answered Oct 16 '25 11:10

David McDermott