TensorFlow Datasets
收藏资源简介:
TensorFlow Datasets 提供多种公共数据集作为 `tf.data.Datasets`,方便与TensorFlow配合使用。
TensorFlow 数据集提供了多种公共数据集,以 `tf.data.Datasets` 的形式呈现,便于与 TensorFlow 集成使用。
数据集概述
数据集列表
数据集使用示例
-
示例代码: 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]
数据集构建器 (DatasetBuilder)
-
功能: 所有数据集通过
tfds.core.DatasetBuilder实现,提供download_and_prepare()和as_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)
数据集信息 (DatasetInfo)
- 示例内容: 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} }""", )
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"]
引用信息
-
引用格式:
@misc{TFDS, title = {{TensorFlow Datasets}, A collection of ready-to-use datasets}, howpublished = {url{https://www.tensorflow.org/datasets}}, }
数据集请求
- 请求方式: 通过 GitHub 问题 提交数据集请求。




