title: How can I import the MNIST dataset that has been manually downloaded?
body: <p>I have been experimenting with a Keras example, which needs to import MNIST data</p>
  
  <pre><code>from keras.datasets import mnist
  import numpy as np
  (x_train, _), (x_test, _) = mnist.load_data()
  </code></pre>
  
  <p>It generates error messages such as <code>Exception: URL fetch failure on https://s3.amazonaws.com/img-datasets/mnist.pkl.gz: None -- [Errno 110] Connection timed out
  </code></p>
  
  <p>It should be related to the network environment I am using. <em>Is there any function or code that can let me directly import the MNIST data set that has been manually downloaded?</em></p>
  
  <p>I tried the following approach </p>
  
  <pre><code>import sys
  import pickle
  import gzip
  f = gzip.open('/data/mnist.pkl.gz', 'rb')
    if sys.version_info &lt; (3,):
      data = pickle.load(f)
  else:
      data = pickle.load(f, encoding='bytes')
  f.close()
  import numpy as np
  (x_train, _), (x_test, _) = data
  </code></pre>
  
  <p>Then I get the following error message</p>
  
  <pre><code>Traceback (most recent call last):
  File "test.py", line 45, in &lt;module&gt;
  (x_train, _), (x_test, _) = data
  ValueError: too many values to unpack (expected 2)
  </code></pre>