TensorFlow Datasets:一系列现成的数据集。

TensorFlow Datasets 是可用于 TensorFlow 或其他 Python 机器学习框架(例如 Jax)的一系列数据集。 所有数据集都作为 tf.data.Datasets 提供,助您实现易用且高性能的输入流水线。 要开始使用,请参阅这份指南以及我们的数据集列表
import tensorflow.compat.v2 as tf
import tensorflow_datasets as tfds

# Construct a tf.data.Dataset
ds = tfds.load('mnist', split='train', shuffle_files=True)

# Build your input pipeline
ds = ds.shuffle(1024).batch(32).prefetch(tf.data.experimental.AUTOTUNE)
for example in ds.take(1):
  image, label = example["image"], example["label"]