【深度学习入门:基于Python的理论与实现图书电子版及各章代码】解决手写数字识别MNIST数据集无法访问问题

仓库:

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 
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值