Registry / ai-ml / tensorflow-datasets

tensorflow-datasets

JSON →
library4.9.10pypypi✓ verified 24d ago

TensorFlow Datasets (TFDS) is a library that provides a comprehensive collection of ready-to-use datasets for machine learning frameworks like TensorFlow, JAX, and PyTorch. It handles the complexities of downloading, preparing, and constructing data into `tf.data.Dataset` or `np.array` objects in a deterministic manner, enabling easy-to-use and high-performance input pipelines. The library maintains an active release cadence, with stable versions typically released every few months, alongside daily nightly builds.

pip install tensorflow-datasets
INSTALL
IMPORT
SIG · TENSORFLOW-DATASET
T
tensorflow-datasets
ai-mlpythonv4.9.10
Install
11.5s avg
Import
1664ms
Disk
468MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.9.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
timeout
glibc
py 3.103.910 runs
installs and imports cleanly · install 11.5s · import 1.664s · 494MB
468MB installed
● package 468MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tfds
import tensorflow_datasets as tfds
tf
import tensorflow as tf
Commonly imported when working with TensorFlow backend, though TFDS can now be used without it for reading datasets.

This quickstart demonstrates how to load the MNIST dataset using `tfds.load()`, retrieve training and testing splits, and configure a basic TensorFlow `tf.data.Dataset` input pipeline. It also shows how to inspect dataset metadata and iterate through a sample batch.

import tensorflow_datasets as tfds import tensorflow as tf # Load the MNIST dataset # It will download and prepare the dataset if not already present. (ds_train, ds_test), info = tfds.load( 'mnist', split=['train', 'test'], shuffle_files=True, as_supervised=True, # Returns (image, label) tuples with_info=True ) # Build your input pipeline ds_train = ds_train.shuffle(1000).batch(32).prefetch(tf.data.AUTOTUNE) ds_test = ds_test.batch(32).prefetch(tf.data.AUTOTUNE) # Iterate and print a sample print(f"Dataset info: {info.name} version {info.version}") for image, label in ds_train.take(1): print(f"Sample image shape: {image.shape}, label: {label.numpy()}")
tfds --version
Debug
Known issues
breakingStarting with v4.9.3, the handling of `None` values for int and float features from `HuggingfaceDatasetBuilder` changed. Instead of converting to `0` or `0.0`, `None` values are now converted to `np.iinfo(dtype).min` or `np.finfo(dtype).min` respectively. This change aligns with NumPy's default behavior for minimum values but can break code relying on the previous `0` default.
fix
Review code that loads Hugging Face datasets and explicitly handle `None` values or convert `min` values if the old `0` behavior is desired.
affects: >=4.9.3
breakingVersion 4.9.0 introduced native support for JAX and PyTorch, making TensorFlow an optional dependency for *reading* datasets. While this enables a 'TensorFlow-less' path, existing codebases heavily integrated with TensorFlow might need review if aiming to leverage TFDS without a full TensorFlow installation, as some functionalities (e.g., `tf.data.Dataset` operations) still depend on TensorFlow.
fix
For non-TensorFlow users, ensure you only use `tfds.as_numpy()` or PyTorch/JAX specific integrations. For TensorFlow users, ensure `tensorflow` is installed if using `tf.data` pipelines, even if not strictly required by TFDS for basic dataset loading.
affects: >=4.9.0
gotchaVersion 4.9.9 pins the `apache-beam` dependency to `<2.65.0` due to internal test fixes. Users with newer versions of `apache-beam` installed globally or in other projects might encounter dependency conflicts or unexpected behavior during dataset generation, especially for large datasets that rely on Beam.
fix
Consider using a virtual environment to manage `apache-beam` versions specific to your `tensorflow-datasets` project, or explicitly downgrade `apache-beam` if conflicts arise.
affects: 4.9.9
gotchaThe `NoShuffleBeamWriter` introduced in v4.9.8, enabled by the `--nondeterministic_order` flag, significantly speeds up dataset generation by omitting shuffling. However, this explicitly removes deterministic order guarantees. If reproducible data order is critical for your experiments or debugging, avoid this flag or manually re-shuffle.
fix
If deterministic order is required, do not use the `--nondeterministic_order` flag. Implement explicit shuffling in your `tf.data` pipeline if randomized order is needed for training, rather than relying on generation-time shuffling.
affects: >=4.9.8
deprecatedThe API for `CroissantBuilder` (used for generating TFDS datasets from Croissant metadata files) underwent changes in v4.9.7. Code interacting with this specific builder for dataset creation will likely require updates.
fix
Consult the official `CroissantBuilder` documentation for the updated API and adjust your dataset generation scripts accordingly.
affects: >=4.9.7
gotchaBy default, `tfds.load()` without specifying the `split` argument returns a dictionary of `tf.data.Dataset` objects (e.g., `{'train': ..., 'test': ...}`). Users often expect direct access to data and might forget to select a split (e.g., `split='train'`) or use `as_supervised=True` for `(features, label)` tuples or `tfds.as_numpy()` for NumPy arrays.
fix
Always specify `split` when loading or iterate over the dictionary to access specific splits. Use `as_supervised=True` for supervised learning tasks to get `(feature, label)` tuples, or `tfds.as_numpy()` to convert to NumPy arrays.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'tensorflow_datasets'
The tensorflow-datasets package is not installed in the current Python environment.
fix
pip install tensorflow-datasets
ValueError: Unknown dataset 'incorrect_dataset_name'
The dataset name provided to `tfds.load()` is either misspelled or the dataset is not recognized by the installed TFDS version.
fix
Verify the dataset name against the official TFDS catalog (tfds.tensorflow.org/catalog) and ensure `tensorflow-datasets` is updated (`pip install --upgrade tensorflow-datasets`). For example, `tfds.load('mnist')`.
tfds.download.DownloadError: Failed to download URL: <some_url>
The dataset source URL could not be reached, the download failed, or the downloaded file is corrupted or does not match the expected checksum.
fix
Check your internet connection. Try clearing the TFDS download cache (`rm -rf ~/tensorflow_datasets/downloads/` or `tfds.core.constants.DATA_DIR`) and re-run. Consider upgrading TFDS (`pip install --upgrade tensorflow-datasets`).
ValueError: Unknown split 'validation' for dataset 'dataset_name'
The specified dataset split (e.g., 'validation', 'val') does not exist for that particular dataset, or is named differently.
fix
Consult the dataset's documentation on the TFDS catalog website (tfds.tensorflow.org) to find available splits, or inspect them programmatically using `tfds.builder('dataset_name').info.splits`. For example, use `'train'` or `'test'` instead.
tfds.core.DatasetNotFoundError: Dataset 'dataset_name' not found.
The specified dataset name is incorrect, misspelled, or the dataset is not available in your installed TFDS version.
fix
Verify the dataset name from official TFDS documentation or by using `tfds.list_builders()` to see available datasets.
Upgrade
Version history
4.9.10latest on PyPI · released May 8, 2026
Audit
Dependencies
tensorflowoptionalOften used in conjunction, but not a strict dependency for reading datasets since v4.9.0. Required for `tf.data.Dataset` operations if not using a TF-less path.
apache-beamoptionalRequired for distributed dataset generation and certain large datasets. Version 4.9.9 pins it to `<2.65.0`.
Agent activity
17 hits · last 30 days
node
14
OpenAI (training)
1
Resources
tensorflow-datasets — pip install tensorflow-datasets · libregistry