W3cubDocs

/TensorFlow C++

tensorflow::ops::DynamicPartition

#include <data_flow_ops.h>

Partitions data into num_partitions tensors using indices from partitions.

Summary

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,

```python 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:

```python 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.

Arguments:

  • scope: A Scope object
  • partitions: Any shape. Indices in the range [0, num_partitions).
  • num_partitions: The number of partitions to output.

Returns:

  • OutputList: The outputs tensor.
Constructors and Destructors
DynamicPartition(const ::tensorflow::Scope & scope, ::tensorflow::Input data, ::tensorflow::Input partitions, int64 num_partitions)
Public attributes
outputs
Public functions
operator[](size_t index) const

Public attributes

outputs

::tensorflow::OutputList outputs

Public functions

DynamicPartition

 DynamicPartition(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input data,
  ::tensorflow::Input partitions,
  int64 num_partitions
)

operator[]

::tensorflow::Output operator[](
  size_t index
) const 

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/dynamic-partition.html