tensorflow数据集加载

------------恢复内容开始------------

1.小型常用数据集加载

 

 1)常用数据集准备 通过keras.datasets直接加载进来

 

 

 加载minst数据集:

 

 

import tensorflow as tf
(x,y),(x_test,y_test) = tf.keras.datasets.mnist.load_data()
print(x.shape)
print(y.shape)
print(x.min(),x.max(),x.mean())
# print(x.shape)
print(x_test.shape)
print(y_test.shape)
print(y[:4])
y_onehot = tf.one_hot(y,depth = 10)
print(y_onehot[:2])

 

 

 

 

print(x.min(),x.max())
print(y[:4])
db = tf.data.Dataset.from_tensor_slices(x_test)
print(next(iter(db)).shape)
db = tf.data.Dataset.from_tensor_slices(x_test,y_test)#转化为tensor的数据集
db = db.shuffle(10000) #打乱操作

.map 数据预处理

 

 .batch

 

 

------------恢复内容结束------------

posted on 2020-11-13 00:00  龑覭  阅读(170)  评论(0编辑  收藏  举报