TensorFlow 导入mnist本地数据(小白入门版,幼儿园小孩也能看懂版)
我靠终于整完了,大部分网上教程都不靠谱
版本:python3.5
TensorFlow2.3.1
Anaconda3
1.下载mnist数据到本地,http://yann.lecun.com/exdb/mnist/,四个链接点进去下载到本地。不要解压!
2.把这四个压缩包放到“c盘:\user:\用户:.keras:\datasets:\fashion-mnist” , 以本人为例,是在.keras文件夹下建立datasets文件夹,datasets下建立fashion-minist文件夹,数据放在fashion-mnist文件夹里。即路径为:C:\Users\hechuan\.keras\datasets\fashion-mnist。
3.在Spyder(Python3.5)中输入代码:
#导入mnist本地数据
import tensorflow as tf
(train_image,train_label),(test_image,test_label)=tf.keras.datasets.fashion_mnist.load_data()
print(train_image.shape,train_image.dtype)
print(train_label.shape,train_label.dtype)
print(test_image.shape,train_image.dtype)
print(test_label.shape,train_label.dtype)
4.点击运行代码
5.运行完成后在Spyder右上角的variable explorer中看到mnist数据已经导入:
Spyder右下角看到已输出minist的训练集测试集的图形和标签的大小(就是下载的那四个压缩包的数据)
OK了,说明本地mnist数据包已经导入TensorFlow。