Computes a tensor such that \(output[i] = {j...} data[j...]\) where the sum is over tuples
j...
such that
segment_ids[j...] == i
. Unlike
SegmentSum
,
segment_ids
need not be sorted and need not cover all values in the full range of valid values.
If the sum is empty for a given segment ID
i
,
output[i] = 0
. If the given segment ID
i
is negative, the value is dropped and will not be added to the sum of the segment.
num_segments
should equal the number of distinct segment IDs.
segment_ids: A tensor whose shape is a prefix of
data.shape
.
Returns:
Output
: Has same shape as data, except for the first
segment_ids.rank
dimensions, which are replaced with a single dimension which has size
num_segments
.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2021-05-14 UTC."],[],[],null,["# tensorflow::ops::UnsortedSegmentSum Class Reference\n\ntensorflow::\nops::\nUnsortedSegmentSum\n=====================================\n\n`\n#include \u003cmath_ops.h\u003e\n`\n\n\nComputes the sum along segments of a tensor.\n\nSummary\n-------\n\n\nRead\n[the section on segmentation](https://tensorflow.org/api_docs/python/tf/math#Segmentation)\nfor an explanation of segments.\n\n\nComputes a tensor such that \\\\(output\\[i\\] = {j...} data\\[j...\\]\\\\) where the sum is over tuples\n`\nj...\n`\nsuch that\n`\nsegment_ids[j...] == i\n`\n. Unlike\n`\n`[SegmentSum](/versions/r2.5/api_docs/cc/class/tensorflow/ops/segment-sum#classtensorflow_1_1ops_1_1_segment_sum)`\n`\n,\n`\nsegment_ids\n`\nneed not be sorted and need not cover all values in the full range of valid values.\n\n\nIf the sum is empty for a given segment ID\n`\ni\n`\n,\n`\noutput[i] = 0\n`\n. If the given segment ID\n`\ni\n`\nis negative, the value is dropped and will not be added to the sum of the segment.\n\n\n`\nnum_segments\n`\nshould equal the number of distinct segment IDs.\n\n\n\u003cbr /\u003e\n\n\n```gdscript\nc = tf.constant([[1,2,3,4], [5,6,7,8], [4,3,2,1]])\ntf.unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2)\n# ==\u003e [[ 5, 5, 5, 5],\n# [5, 6, 7, 8]]\n```\n\n\u003cbr /\u003e\n\n\nArgs:\n\n- scope: A [Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- segment_ids: A tensor whose shape is a prefix of `\n data.shape\n ` .\n\n\u003cbr /\u003e\n\n\nReturns:\n\n- `\n `[Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)`\n ` : Has same shape as data, except for the first `\n segment_ids.rank\n ` dimensions, which are replaced with a single dimension which has size `\n num_segments\n ` .\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| ` `[UnsortedSegmentSum](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1a523a2af71c68956739def8e73da562ce)` (const :: `[tensorflow::Scope](/versions/r2.5/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` data, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` segment_ids, :: `[tensorflow::Input](/versions/r2.5/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` num_segments) ` ||\n\n| ### Public attributes ||\n|--------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|\n| ` `[operation](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1abea8a0230165d39d5462f3b026641a87)` ` | ` `[Operation](/versions/r2.5/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation)` ` |\n| ` `[output](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1ace1d27d6d7cc362c688e1a08ea92c40f)` ` | ` :: `[tensorflow::Output](/versions/r2.5/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output)` ` |\n\n| ### Public functions ||\n|------------------------------------------------------------------------------------------------------------------------------------|--------------------------|\n| ` `[node](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1aeb60f49f613fc351fc9cc30a55a66486)` () const ` | ` ::tensorflow::Node * ` |\n| ` `[operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1a11030ed77273925e7bbdf6ba24defdd9)` () const ` | ` ` |\n| ` `[operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_unsorted_segment_sum_1ac3c5ac1a7b8d9c7b5047dff05040dff1)` () const ` | ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### UnsortedSegmentSum\n\n```gdscript\n UnsortedSegmentSum(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input data,\n ::tensorflow::Input segment_ids,\n ::tensorflow::Input num_segments\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]