How can I import the MNIST dataset that has been manually downloaded?

前端 未结 4 1118
北海茫月
北海茫月 2021-02-05 18:36

I have been experimenting with a Keras example, which needs to import MNIST data

from keras.datasets import mnist
import numpy as np
(x_train, _), (x_test, _) =          


        
4条回答
  •  无人及你
    2021-02-05 19:03

    Well, the keras.datasets.mnist file is really short. You can manually simulate the same action, that is:

    1. Download a dataset from https://s3.amazonaws.com/img-datasets/mnist.pkl.gz
    2. .

      import gzip
      f = gzip.open('mnist.pkl.gz', 'rb')
      if sys.version_info < (3,):
          data = cPickle.load(f)
      else:
          data = cPickle.load(f, encoding='bytes')
      f.close()
      (x_train, _), (x_test, _) = data
      

提交回复
热议问题