tf.raw_ops.MapAndBatchDataset
Stay organized with collections
Save and categorize content based on your preferences.
Creates a dataset that fuses mapping with batching.
tf.raw_ops.MapAndBatchDataset(
input_dataset,
other_arguments,
batch_size,
num_parallel_calls,
drop_remainder,
f,
output_types,
output_shapes,
preserve_cardinality=False,
metadata='',
name=None
)
Creates a dataset that applies f
to the outputs of input_dataset
and then
batches batch_size
of them.
Unlike a "MapDataset", which applies f
sequentially, this dataset invokes up
to batch_size * num_parallel_batches
copies of f
in parallel.
Args |
input_dataset
|
A Tensor of type variant .
A variant tensor representing the input dataset.
|
other_arguments
|
A list of Tensor objects.
A list of tensors, typically values that were captured when building a closure
for f .
|
batch_size
|
A Tensor of type int64 .
A scalar representing the number of elements to accumulate in a
batch. It determines the number of concurrent invocations of f that process
elements from input_dataset in parallel.
|
num_parallel_calls
|
A Tensor of type int64 .
A scalar representing the maximum number of parallel invocations of the map_fn
function. Applying the map_fn on consecutive input elements in parallel has
the potential to improve input pipeline throughput.
|
drop_remainder
|
A Tensor of type bool .
A scalar representing whether the last batch should be dropped in case its size
is smaller than desired.
|
f
|
A function decorated with @Defun.
A function to apply to the outputs of input_dataset .
|
output_types
|
A list of tf.DTypes that has length >= 1 .
|
output_shapes
|
A list of shapes (each a tf.TensorShape or list of ints ) that has length >= 1 .
|
preserve_cardinality
|
An optional bool . Defaults to False .
|
metadata
|
An optional string . Defaults to "" .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor of type variant .
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.MapAndBatchDataset\n\n\u003cbr /\u003e\n\nCreates a dataset that fuses mapping with batching.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.raw_ops.MapAndBatchDataset`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/MapAndBatchDataset)\n\n\u003cbr /\u003e\n\n tf.raw_ops.MapAndBatchDataset(\n input_dataset,\n other_arguments,\n batch_size,\n num_parallel_calls,\n drop_remainder,\n f,\n output_types,\n output_shapes,\n preserve_cardinality=False,\n metadata='',\n name=None\n )\n\nCreates a dataset that applies `f` to the outputs of `input_dataset` and then\nbatches `batch_size` of them.\n\nUnlike a \"MapDataset\", which applies `f` sequentially, this dataset invokes up\nto `batch_size * num_parallel_batches` copies of `f` in parallel.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input_dataset` | A `Tensor` of type `variant`. A variant tensor representing the input dataset. |\n| `other_arguments` | A list of `Tensor` objects. A list of tensors, typically values that were captured when building a closure for `f`. |\n| `batch_size` | A `Tensor` of type `int64`. A scalar representing the number of elements to accumulate in a batch. It determines the number of concurrent invocations of `f` that process elements from `input_dataset` in parallel. |\n| `num_parallel_calls` | A `Tensor` of type `int64`. A scalar representing the maximum number of parallel invocations of the `map_fn` function. Applying the `map_fn` on consecutive input elements in parallel has the potential to improve input pipeline throughput. |\n| `drop_remainder` | A `Tensor` of type `bool`. A scalar representing whether the last batch should be dropped in case its size is smaller than desired. |\n| `f` | A function decorated with @Defun. A function to apply to the outputs of `input_dataset`. |\n| `output_types` | A list of `tf.DTypes` that has length `\u003e= 1`. |\n| `output_shapes` | A list of shapes (each a [`tf.TensorShape`](../../tf/TensorShape) or list of `ints`) that has length `\u003e= 1`. |\n| `preserve_cardinality` | An optional `bool`. Defaults to `False`. |\n| `metadata` | An optional `string`. Defaults to `\"\"`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor` of type `variant`. ||\n\n\u003cbr /\u003e"]]