TensorFlow Datasets
收藏数据集概述
数据集列表
TensorFlow Datasets 提供多种公共数据集,可通过以下链接查看完整列表: List of datasets
数据集使用示例
- MNIST 数据集:
-
加载与使用示例: python import tensorflow_datasets as tfds import tensorflow as tf
ds_train = tfds.load(mnist, split=train, shuffle_files=True) ds_train = ds_train.shuffle(1000).batch(128).prefetch(10) for features in ds_train.take(1): image, label = features[image], features[label]
-
数据集信息: python tfds.core.DatasetInfo( name=mnist, version=3.0.1, description=The MNIST database of handwritten digits., homepage=http://yann.lecun.com/exdb/mnist/, features=FeaturesDict({ image: Image(shape=(28, 28, 1), dtype=tf.uint8), label: ClassLabel(shape=(), dtype=tf.int64, num_classes=10), }), total_num_examples=70000, splits={ test: 10000, train: 60000, }, supervised_keys=(image, label), citation="""@article{lecun2010mnist, title={MNIST handwritten digit database}, author={LeCun, Yann and Cortes, Corinna and Burges, CJ}, journal={ATT Labs [Online]. Available: http://yann.lecun.com/exdb/mnist}, volume={2}, year={2010} }""", )
-
数据集构建器 (DatasetBuilder)
-
数据集构建器用于控制数据集的下载和准备过程,以及构建
tf.data.Dataset。 -
使用示例: python import tensorflow_datasets as tfds
mnist_builder = tfds.builder(mnist) mnist_builder.download_and_prepare() ds = mnist_builder.as_dataset(split=train) info = mnist_builder.info print(info)
NumPy 使用
- 使用
tfds.as_numpy可以将tf.data.Dataset转换为 NumPy 数组,方便在模型中使用。 - 使用示例: python train_ds = tfds.load("mnist", split="train") train_ds = train_ds.shuffle(1024).batch(128).repeat(5).prefetch(10) for example in tfds.as_numpy(train_ds): numpy_images, numpy_labels = example["image"], example["label"]
引用信息
-
使用
tensorflow-datasets时的引用格式:@misc{TFDS, title = {{TensorFlow Datasets}, A collection of ready-to-use datasets}, howpublished = {url{https://www.tensorflow.org/datasets}}, }
请求新数据集
- 可以通过 GitHub 提交数据集请求,并参与现有请求的投票。
- 请求链接:Dataset request GitHub issue




