<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L170-L992) |

Information about a dataset.

    tfds.core.DatasetInfo(
        *,
        builder: (DatasetIdentity | Any),
        description: (str | None) = None,
        features: (feature_lib.FeatureConnector | None) = None,
        supervised_keys: (SupervisedKeysType | None) = None,
        disable_shuffling: bool = False,
        nondeterministic_order: bool = False,
        homepage: (str | None) = None,
        citation: (str | None) = None,
        metadata: (Metadata | None) = None,
        license: (str | None) = None,
        redistribution_info: (dict[str, str] | None) = None,
        split_dict: (splits_lib.SplitDict | None) = None,
        alternative_file_formats: (Sequence[str | file_adapters.FileFormat] | None) = None,
        is_blocked: (str | None) = None
    )

`DatasetInfo` documents datasets, including its name, version, and features.
See the constructor arguments and properties for a full list.

> [!NOTE]
> **Note:** Not all fields are known if the dataset hasn't been generated yet (before the first `builder.download_and_prepare()` call). For example splits names or number of examples might be missing (as they are computed at dataset creation time).

<br />

<br />

<br />

| ## Args ||
|---|---|
| `builder` | `DatasetBuilder` or `DatasetIdentity`. The dataset builder or identity will be used to populate this info. |
| `description` | `str`, description of this dataset. |
| `features` | [`tfds.features.FeaturesDict`](https://www.tensorflow.org/datasets/api_docs/python/tfds/features/FeaturesDict), Information on the feature dict of the [`tf.data.Dataset()`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset) object from the `builder.as_dataset()` method. |
| `supervised_keys` | Specifies the input structure for supervised learning, if applicable for the dataset, used with "as_supervised". The keys correspond to the feature names to select in `info.features`. When calling [`tfds.core.DatasetBuilder.as_dataset()`](https://www.tensorflow.org/datasets/api_docs/python/tfds/core/DatasetBuilder#as_dataset) with `as_supervised=True`, the [`tf.data.Dataset`](https://www.tensorflow.org/api_docs/python/tf/data/Dataset) object will yield the structure defined by the keys passed here, instead of that defined by the `features` argument. Typically this is a `(input_key, target_key)` tuple, and the dataset yields a tuple of tensors `(input, target)` tensors. <br /> To yield a more complex structure, pass a tuple of [`tf.nest`](https://www.tensorflow.org/api_docs/python/tf/nest) compatible structures of feature keys. The resulting `Dataset` will yield structures with each key replaced by the coresponding tensor. For example, passing a triple of keys would return a dataset that yields `(feature, target, sample_weights)` triples for keras. Using `supervised_keys=({'a':'a','b':'b'}, 'c')` would create a dataset yielding a tuple with a dictionary of features in the `features` position. Note that selecting features in nested [`tfds.features.FeaturesDict`](https://www.tensorflow.org/datasets/api_docs/python/tfds/features/FeaturesDict) objects is not supported. |
| `disable_shuffling` | `bool`, specifies whether to shuffle the examples. |
| `nondeterministic_order` | `bool`, if True and the dataset uses beam, it will use `NoShuffleBeamWriter` which does not assure deterministic shuffling when writing' examples to disk. This might result in quicker dataset preparation. |
| `homepage` | `str`, optional, the homepage for this dataset. |
| `citation` | `str`, optional, the citation to use for this dataset. |
| `metadata` | [`tfds.core.Metadata`](https://www.tensorflow.org/datasets/api_docs/python/tfds/core/Metadata), additonal object which will be stored/restored with the dataset. This allows for storing additional information with the dataset. |
| `license` | license of the dataset. |
| `redistribution_info` | information needed for redistribution, as specified in `dataset_info_pb2.RedistributionInfo`. The content of the `license` subfield will automatically be written to a LICENSE file stored with the dataset. |
| `split_dict` | information about the splits in this dataset. |
| `alternative_file_formats` | alternative file formats that are availablefor this dataset. |
| `is_blocked` | A message explaining why the dataset, in its version and config, is blocked. If empty or None, the dataset is not blocked. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `alternative_file_formats` | <br /> <br /> |
| `as_json` | <br /> <br /> |
| `as_proto` | <br /> <br /> |
| `as_proto_with_features` | <br /> <br /> |
| `citation` | <br /> <br /> |
| `config_description` | <br /> <br /> |
| `config_name` | <br /> <br /> |
| `config_tags` | <br /> <br /> |
| `data_dir` | <br /> <br /> |
| `dataset_size` | Generated dataset files size, in bytes. |
| `description` | <br /> <br /> |
| `disable_shuffling` | <br /> <br /> |
| `download_size` | Downloaded files size, in bytes. |
| `features` | <br /> <br /> |
| `file_format` | <br /> <br /> |
| `full_name` | Full canonical name: (//). |
| `homepage` | <br /> <br /> |
| `initialized` | Whether DatasetInfo has been fully initialized. |
| `is_blocked` | <br /> <br /> |
| `metadata` | <br /> <br /> |
| `module_name` | <br /> <br /> |
| `name` | <br /> <br /> |
| `nondeterministic_order` | <br /> <br /> |
| `redistribution_info` | <br /> <br /> |
| `release_notes` | <br /> <br /> |
| `splits` | <br /> <br /> |
| `supervised_keys` | <br /> <br /> |
| `version` | <br /> <br /> |

<br />

## Methods

### `add_alternative_file_format`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L553-L565)

    add_alternative_file_format(
        file_format: (str | file_adapters.FileFormat)
    ) -> None

Adds an alternative file format to the dataset info.

### `add_file_data_source_access`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L814-L838)

    add_file_data_source_access(
        path: (epath.PathLike | Iterable[epath.PathLike]), url: (str | None) = None
    ) -> None

Records that the given query was used to generate this dataset.

<br />

<br />

<br />

| Arguments ||
|---|---|
| `path` | path or paths of files that were read. Can be a file pattern. Multiple paths or patterns can be specified as a comma-separated string or a list. |
| `url` | URL referring to the data being used. |

<br />

### `add_sql_data_source_access`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L853-L863)

    add_sql_data_source_access(
        sql_query: str
    ) -> None

Records that the given query was used to generate this dataset.

### `add_tfds_data_source_access`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L865-L880)

    add_tfds_data_source_access(
        dataset_reference: naming.DatasetReference, url: (str | None) = None
    ) -> None

Records that the given query was used to generate this dataset.

<br />

<br />

<br />

| Args ||
|---|---|
| `dataset_reference` | <br /> <br /> |
| `url` | a URL referring to the TFDS dataset. |

<br />

### `add_url_access`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L840-L851)

    add_url_access(
        url: str, checksum: (str | None) = None
    ) -> None

Records the URL used to generate this dataset.

### `available_file_formats`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L567-L572)

    available_file_formats() -> set[file_adapters.FileFormat]

### `from_proto`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L326-L361)

    @classmethod
    from_proto(
        builder, proto: dataset_info_pb2.DatasetInfo
    ) -> 'DatasetInfo'

Instantiates DatasetInfo from the given builder and proto.

### `initialize_from_bucket`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L882-L900)

    initialize_from_bucket() -> None

Initialize DatasetInfo from GCS bucket info files.

### `read_from_directory`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L696-L812)

    read_from_directory(
        dataset_info_dir: epath.PathLike
    ) -> None

Update DatasetInfo from the metadata files in `dataset_info_dir`.

This function updates all the dynamically generated fields (num_examples,
hash, time of creation,...) of the DatasetInfo.

This will overwrite all previous metadata.

<br />

<br />

<br />

| Args ||
|---|---|
| `dataset_info_dir` | The directory containing the metadata file. This should be the root directory of a specific dataset version. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `DatasetInfoFileError` | If the dataset_info.json can't be read. |

<br />

### `set_file_format`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L493-L551)

    set_file_format(
        file_format: (None | str | file_adapters.FileFormat),
        override: bool = False,
        override_if_initialized: bool = False
    ) -> None

Internal function to define the file format.

The file format is set during `FileReaderBuilder.__init__`,
not [`DatasetInfo.init`](https://www.tensorflow.org/datasets/api_docs/python/tfds/core/DatasetInfo#__init__).

<br />

<br />

<br />

| Args ||
|---|---|
| `file_format` | The file format. |
| `override` | Whether the file format should be overridden if it is already set. |
| `override_if_initialized` | Whether the file format should be overridden if the DatasetInfo is already fully initialized. |

<br />

<br />

<br />

<br />

| Raises ||
|---|---|
| `ValueError` | if the file format was already set and the `override` parameter was False. |
| `RuntimeError` | if an incorrect combination of options is given, e.g. `override=True` when the DatasetInfo is already fully initialized. |

<br />

### `set_is_blocked`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L469-L470)

    set_is_blocked(
        is_blocked: str
    ) -> None

### `set_nondeterministic_order`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L416-L417)

    set_nondeterministic_order(
        nondeterministic_order: bool
    ) -> None

### `set_splits`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L578-L634)

    set_splits(
        split_dict: splits_lib.SplitDict
    ) -> None

Split setter (private method).

### `update_data_dir`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L636-L651)

    update_data_dir(
        data_dir: str
    ) -> None

Updates the data dir for each split.

### `write_dataset_info_json`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L692-L694)

    write_dataset_info_json(
        dataset_info_dir: epath.PathLike
    ) -> None

Writes only the dataset_info.json file to the given directory.

### `write_to_directory`

[View source](https://github.com/tensorflow/datasets/blob/v4.9.10/tensorflow_datasets/core/dataset_info.py#L662-L690)

    write_to_directory(
        dataset_info_dir: epath.PathLike, all_metadata=True
    ) -> None

Write `DatasetInfo` as JSON to `dataset_info_dir` + labels \& features.

<br />

<br />

<br />

| Args ||
|---|---|
| `dataset_info_dir` | path to directory in which to save the `dataset_info.json` file, as well as `features.json` and `*.labels.txt` if applicable. |
| `all_metadata` | defaults to True. If False, will not write metadata which may have an impact on how the data is read (features.json). Should be set to True whenever `write_to_directory` is called for the first time for a new dataset. |

<br />