tensorflow下数据集MNIST下载源代码

来源:互联网 发布:java 软引用 弱引用 编辑:程序博客网 时间:2024/05/16 02:08

本人Tensorflow新手,在下载经典数据集MNIST时遇到问题,input_data.py脚本下载不了。在此给出此文件源代码。
这里写图片描述

# Copyright 2015 The TensorFlow Authors. All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at##     http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.# =============================================================================="""Functions for downloading and reading MNIST data."""from __future__ import absolute_importfrom __future__ import divisionfrom __future__ import print_functionimport gzipimport osimport tempfileimport numpyfrom six.moves import urllibfrom six.moves import xrange  # pylint: disable=redefined-builtinimport tensorflow as tffrom tensorflow.contrib.learn.python.learn.datasets.mnist import read_data_sets

将上述脚本运行后即可得到数据集。(注意第一次运行此脚本需要在国外网站上下载数据,因此需要翻墙)
以后再调用此数据集时加上如下代码即可:

import input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)     #文件夹名字 MNIST_data/可以自己指定

到此问题得以解决。

阅读全文
'); })();
0 0
原创粉丝点击
热门IT博客
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 江苏苏宁吧 江苏在那里 江苏服装厂 江苏专升本 江苏人才 专接本江苏 江苏师大 江苏信息 自考江苏 到江苏 江苏遴选 江苏火锅 江苏招聘网 江苏招工 江苏舜天 江苏大全 江苏省行政区划 江苏名师空中课堂 江苏科技大学 江苏省中医院 江苏海洋大学 江苏名师空中 江苏职业学院 江苏理工学院 江苏人民医院 江苏连云港爆炸 江苏有什么好玩的地方 江苏哪里好玩 江苏旅游景点 江苏好玩的地方 江苏旅游景点大全 江苏旅游景点排行 江苏什么地方好玩 江苏旅游景点大全排行榜 江苏好玩的景点 江苏省旅游景点介绍 江苏有哪些好玩的地方 江苏省旅游景点大全 江苏有什么好玩的 江苏省旅游景点 江苏是哪个省