仓库:
deep_learning_from_scratch_python
仓库中有各章代码和电子版图书。
问题描述:
在学习《深度学习入门:基于Python的理论与实现》高清中文版时,参考了GitHub代码:https://github.com/ZhangXinNan/deep_learning_from_scratch的代码。
但代码需要访问数据集 MNIST handwritten digit database,而这个官方的数据集无法直接访问,提示以下错误,所以运行代码也会出现问题。
解决方法:
找到了 备份数据集:mnist数据集,从中下载了四个文件:
将四个文件放在了https://github.com/ZhangXinNan/deep_learning_from_scratch的dataset/下。
现在有了离线的数据集文件,但是https://github.com/ZhangXinNan/deep_learning_from_scratch/dataset/mnist.py文件中是在线的下载方案,mnist.py的代码如下:
# coding: utf-8
try:
import urllib.request
except ImportError:
raise ImportError('You should use Python 3.x')
import os.path
import gzip
import pickle
import os
import numpy as np
url_base = 'http://yann.lecun.com/exdb/mnist/'
key_file = {
'train_img':'train-images-idx3-ubyte.gz',
'train_label':'train-labels-idx1-ubyte.gz',
'test_img':'t10k-images-idx3-ubyte.gz',
'test_label':'t10k-labels-idx1-ubyte.gz'
}
dataset_dir = os.path.dirname(os.path.abspath(__file__))
save_file = dataset_dir + "/mnist.pkl"
train_num = 60000
test_num = 10000
img_dim