tf.raw_ops.DynamicPartition
Stay organized with collections
Save and categorize content based on your preferences.
Partitions data
into num_partitions
tensors using indices from partitions
.
tf.raw_ops.DynamicPartition(
data, partitions, num_partitions, name=None
)
For each index tuple js
of size partitions.ndim
, the slice data[js, ...]
becomes part of outputs[partitions[js]]
. The slices with partitions[js] = i
are placed in outputs[i]
in lexicographic order of js
, and the first
dimension of outputs[i]
is the number of entries in partitions
equal to i
.
In detail,
outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]
outputs[i] = pack([data[js, ...] for js if partitions[js] == i])
data.shape
must start with partitions.shape
.
For example:
# Scalar partitions.
partitions = 1
num_partitions = 2
data = [10, 20]
outputs[0] = [] # Empty with shape [0, 2]
outputs[1] = [[10, 20]]
# Vector partitions.
partitions = [0, 0, 1, 1, 0]
num_partitions = 2
data = [10, 20, 30, 40, 50]
outputs[0] = [10, 20, 50]
outputs[1] = [30, 40]
See dynamic_stitch
for an example on how to merge partitions back.
Raises |
InvalidArgumentError in following cases:
- If partitions is not in range
[0, num_partiions)
- If
partitions.shape does not match prefix of data.shape argument.
|
Args |
data
|
A Tensor .
|
partitions
|
A Tensor of type int32 .
Any shape. Indices in the range [0, num_partitions) .
|
num_partitions
|
An int that is >= 1 .
The number of partitions to output.
|
name
|
A name for the operation (optional).
|
Returns |
A list of num_partitions Tensor objects with the same type as data .
|
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.DynamicPartition\n\n\u003cbr /\u003e\n\nPartitions `data` into `num_partitions` tensors using indices from `partitions`.\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.DynamicPartition`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/DynamicPartition)\n\n\u003cbr /\u003e\n\n tf.raw_ops.DynamicPartition(\n data, partitions, num_partitions, name=None\n )\n\nFor each index tuple `js` of size `partitions.ndim`, the slice `data[js, ...]`\nbecomes part of `outputs[partitions[js]]`. The slices with `partitions[js] = i`\nare placed in `outputs[i]` in lexicographic order of `js`, and the first\ndimension of `outputs[i]` is the number of entries in `partitions` equal to `i`.\nIn detail, \n\n outputs[i].shape = [sum(partitions == i)] + data.shape[partitions.ndim:]\n\n outputs[i] = pack([data[js, ...] for js if partitions[js] == i])\n\n`data.shape` must start with `partitions.shape`.\n\n#### For example:\n\n # Scalar partitions.\n partitions = 1\n num_partitions = 2\n data = [10, 20]\n outputs[0] = [] # Empty with shape [0, 2]\n outputs[1] = [[10, 20]]\n\n # Vector partitions.\n partitions = [0, 0, 1, 1, 0]\n num_partitions = 2\n data = [10, 20, 30, 40, 50]\n outputs[0] = [10, 20, 50]\n outputs[1] = [30, 40]\n\nSee `dynamic_stitch` for an example on how to merge partitions back. \n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|---|---|\n| \u003cbr /\u003e - `InvalidArgumentError` in following cases: - If partitions is not in range `[0, num_partiions)` - If `partitions.shape` does not match prefix of `data.shape` argument. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------|------------------------------------------------------------------------------------|\n| `data` | A `Tensor`. |\n| `partitions` | A `Tensor` of type `int32`. Any shape. Indices in the range `[0, num_partitions)`. |\n| `num_partitions` | An `int` that is `\u003e= 1`. The number of partitions to output. |\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 list of `num_partitions` `Tensor` objects with the same type as `data`. ||\n\n\u003cbr /\u003e"]]