怎么样使用tensorflow导入已经下载好的mnist数据集?
import tensorflow.examples.tutorials.mnist.input_data as input_datamnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
■网友
下载好的文件放到代码目录下就可以了呀,调用read_data_sets()的时候第一个路径参数写\u0026#39;.\u0026#39;,表示当前目录,mnist.py会判断是否下载,因为源码里调用的函数是maybe_download(),这个函数会判断本地是否已经有文件了。
如果还不行,就直接阅读tensorflow/contrib/learn/python/learn/datasets/mnist.py源文件,将相应的读取代码稍加重组织粘贴到程序中。
■网友
from tensorflow.examples.tutorials.mnist import input_dataMNIST_data_folder=\u0026#39;\u0026#39; mnist data 的文件夹\u0026#39;\u0026#39;mnist=input_data.read_data_sets(MNIST_data_folder,one_hot=True)print mnist.train.next_batch(1)
■网友
The Environment: Ubuntu + Anaconda + Jupyter notebook
My Anaconda is installed in default in the directory of the \u0026#39;/home\u0026#39;
When run the code below in the reference documentation:from tensorflow.examples.tutorials.mnist import input_dataimport tensorflow as tfmnist = input_data.read_data_sets(\u0026#39;MNIST_data\u0026#39;, one_hot=True)...In default, the program would download the dataset from the official website.
Since you have downloaded the MNIST dataset, named (they all are not unpacked) :
t10k-images-idx3-ubyte.gzt10k-labels-idx1-ubyte.gztrain-images-idx3-ubyte.gz train-labels-idx1-ubyte.gzYou should put them in the \u0026#39;/home/anaconda/\u0026#39;MNIST_data\u0026#39;\u0026#39;
Then the input_data.py would recognize then folder \u0026#39;MNIST_data\u0026#39; have dataset or not, if yes, you load the downloading dataset successfully.
■网友
假设你下载好的mnist保存路径为:/home/gkxiao/work/keras/mnist.npz
npz是numpy格式,所以用np的load函数,示例如下:import numpy as npf = np.load(\u0026#39;/home/gkxiao/work/keras/mnist.npz\u0026#39;)x_train, y_train = f, fx_test, y_test = f, ff.closex_train, x_test = x_train / 255.0, x_test / 255.0
■网友
from tensorflow.examples.tutorials.mnist import input_data
MNIST_data_folder="D:\\\\TestTensorflow\\\\……\\\\MNIST_data"
mnist=input_data.read_data_sets(MNIST_data_folder,one_hot=True)
把本地下载好的数据路径加进去,要用\\\\
■网友
看我这个去吧,这个应该可以入门了,别看极客学院的那群骗子
keras mnist 训练完成后识别自己的图出现错误?
■网友
【怎么样使用tensorflow导入已经下载好的mnist数据集?】 创建目录MNIST_data,把下载好的数据放到MNIST_data目录即可
推荐阅读
- 『先进』长江流域最先进洗舱站在宁投运 油可分离回收,水能循环使用
- 汽车|冬天怎样让车内温度快速升高?座椅加热的最佳使用方式二,外循环的作用总结
- 汽车|迈凯伦Artura不再使用迈凯伦祖传V8引擎了?
- dart这编程语言现在发展怎么样了,语法与Java,c#很相似,甚至更简洁
- 青年|一汽奔腾T77怎么样?车主吐槽:后排座椅太短,和坐小板凳似的
- python的html5lib这个库咋使用啊我在网上也没有找到相关文档
- 电商网站支付流程的流失率是怎么样的从用户点击充值/支付按钮,到支付完成,其中每一步的流失比率都是咋样的
- 作为一个服装供应商,怎么样与淘宝卖家沟通才能卖出自己的产品或者拿到订单
- 在丁丁租房工作的感受是怎么样的
- 城市数据团是怎么样一个团队
