-
找到本地keras目錄下的mnist.py文件
通常在這個目錄下。
..\Anaconda3\Lib\site-packages\keras\datasets
-
下載mnist.npz文件到本地
下載鏈接如下。
https://pan.baidu.com/s/1C3c2Vn-_616GqeEn7hQQ2Q -
修改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,去盡請使用吧 **