Loads the named dataset into a `tf.data.Dataset`. `tfds.load` is a convenience method that: 1. Fetch the `tfds.core.DatasetBuilder` by name: ```python builder = tfds.builder(name, data_dir=data_dir, **builder_kwargs) ``` 2. Generate the data (when `download=True`): ```
(
name: str,
*,
split: Tree[splits_lib.SplitArg] | None = None,
data_dir: epath.PathLike | None = None,
batch_size: int | None = None,
shuffle_files: bool = False,
download: bool = True,
as_supervised: bool = False,
decoders: TreeDict[decode.partial_decode.DecoderArg] | None = None,
read_config: read_config_lib.ReadConfig | None = None,
with_info: bool = False,
builder_kwargs: dict[str, Any] | None = None,
download_and_prepare_kwargs: dict[str, Any] | None = None,
as_dataset_kwargs: dict[str, Any] | None = None,
try_gcs: bool = False,
file_format: str | file_adapters.FileFormat | None = None,
)
| 521 | |
| 522 | @tfds_logging.load() |
| 523 | def load( |
| 524 | name: str, |
| 525 | *, |
| 526 | split: Tree[splits_lib.SplitArg] | None = None, |
| 527 | data_dir: epath.PathLike | None = None, |
| 528 | batch_size: int | None = None, |
| 529 | shuffle_files: bool = False, |
| 530 | download: bool = True, |
| 531 | as_supervised: bool = False, |
| 532 | decoders: TreeDict[decode.partial_decode.DecoderArg] | None = None, |
| 533 | read_config: read_config_lib.ReadConfig | None = None, |
| 534 | with_info: bool = False, |
| 535 | builder_kwargs: dict[str, Any] | None = None, |
| 536 | download_and_prepare_kwargs: dict[str, Any] | None = None, |
| 537 | as_dataset_kwargs: dict[str, Any] | None = None, |
| 538 | try_gcs: bool = False, |
| 539 | file_format: str | file_adapters.FileFormat | None = None, |
| 540 | ): |
| 541 | # pylint: disable=line-too-long |
| 542 | """Loads the named dataset into a `tf.data.Dataset`. |
| 543 | |
| 544 | `tfds.load` is a convenience method that: |
| 545 | |
| 546 | 1. Fetch the `tfds.core.DatasetBuilder` by name: |
| 547 | |
| 548 | ```python |
| 549 | builder = tfds.builder(name, data_dir=data_dir, **builder_kwargs) |
| 550 | ``` |
| 551 | |
| 552 | 2. Generate the data (when `download=True`): |
| 553 | |
| 554 | ```python |
| 555 | builder.download_and_prepare(**download_and_prepare_kwargs) |
| 556 | ``` |
| 557 | |
| 558 | 3. Load the `tf.data.Dataset` object: |
| 559 | |
| 560 | ```python |
| 561 | ds = builder.as_dataset( |
| 562 | split=split, |
| 563 | as_supervised=as_supervised, |
| 564 | shuffle_files=shuffle_files, |
| 565 | read_config=read_config, |
| 566 | decoders=decoders, |
| 567 | **as_dataset_kwargs, |
| 568 | ) |
| 569 | ``` |
| 570 | |
| 571 | See: https://www.tensorflow.org/datasets/overview#load_a_dataset for more |
| 572 | examples. |
| 573 | |
| 574 | If you'd like NumPy arrays instead of `tf.data.Dataset`s or `tf.Tensor`s, |
| 575 | you can pass the return value to `tfds.as_numpy`. |
| 576 | |
| 577 | **Warning**: calling this function might potentially trigger the download |
| 578 | of hundreds of GiB to disk. Refer to the `download` argument. |
| 579 | |
| 580 | Args: |
no test coverage detected