TensorFlow Datasets
收藏数据集概述
TensorFlow Datasets(TFDS)是一个提供多种公共数据集的库,这些数据集可以直接作为tf.data.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)
-
数据集信息:
tfds.core.DatasetInfo( name=mnist, version=1.0.0, 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: <tfds.core.SplitInfo num_examples=10000>, train: <tfds.core.SplitInfo num_examples=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:
-
数据集构建器使用示例: 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
-
NumPy使用
- tfds.as_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"]
数据集引用
-
引用格式:
@misc{TFDS, title = {{TensorFlow Datasets}, A collection of ready-to-use datasets}, howpublished = {url{https://www.tensorflow.org/datasets}}, }
数据集请求与贡献
- 添加数据集指南:添加数据集
- 数据集请求:数据集请求GitHub问题
免责声明
- 使用数据集前需确认数据集的使用许可和版权信息。
- 数据集所有者可更新数据集信息或请求移除数据集。




