Path: blob/master/site/zh-cn/tutorials/load_data/numpy.ipynb
25118 views
Kernel: Python 3
Copyright 2019 The TensorFlow Authors.
In [ ]:
使用 tf.data 加载 NumPy 数据
本教程提供了一个将数据从 NumPy 数组加载到 tf.data.Dataset
中的示例。
此示例从 .npz
文件加载 MNIST 数据集。但是,NumPy 数组的来源并不重要。
安装
In [ ]:
从 .npz
文件中加载
In [ ]:
使用 tf.data.Dataset
加载 NumPy 数组
假设您有一个示例数组和相应的标签数组,请将两个数组作为元组传递给 tf.data.Dataset.from_tensor_slices
以创建 tf.data.Dataset
。
In [ ]:
使用该数据集
打乱和批次化数据集
In [ ]:
建立和训练模型
In [ ]:
In [ ]:
In [ ]: