1. 找到本地keras目录下的mnist.py文件
    通常在这个目录下。
    ..\Anaconda3\Lib\site-packages\keras\datasets

  2. 下载mnist.npz文件到本地
    下载链接如下。
    https://pan.baidu.com/s/1C3c2Vn-_616GqeEn7hQQ2Q

  3. 修改mnist.py文件为以下内容,并保存

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from ..utils.data_utils import get_file
import numpy as np

#cui 2018.07.08,修改

def load_data(path='mnist.npz'):
    """Loads the MNIST dataset.

    # Arguments
        path: path where to cache the dataset locally
            (relative to ~/.keras/datasets).

    # Returns
        Tuple of Numpy arrays: `(x_train, y_train), (x_test, y_test)`.
    """
    path = 'E:/Data/Mnist/mnist.npz' #此处的path为你刚刚防止mnist.py的目录。注意斜杠
    f = np.load(path)
    x_train, y_train = f['x_train'], f['y_train']
    x_test, y_test = f['x_test'], f['y_test']
    f.close()
    return (x_train, y_train), (x_test, y_test)

** OK,去尽请使用吧 **

相关文章:

  • 2022-12-23
  • 2022-01-21
  • 2021-08-23
  • 2021-06-04
  • 2021-09-23
  • 2022-12-23
  • 2021-09-27
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
相关资源
相似解决方案