เทนเซอร์โฟลว์:: ปฏิบัติการ:: SparseSegmentSumWithNumSegments

#include <math_ops.h>

คำนวณผลรวมตามส่วนที่กระจัดกระจายของเมตริกซ์

สรุป

เช่นเดียวกับ SparseSegmentSum แต่อนุญาตให้ไม่มี ID ใน segment_ids หากรหัสหายไป เทนเซอร์ output ที่ตำแหน่งนั้นจะเป็นศูนย์

อ่าน ส่วนเกี่ยวกับการแบ่งส่วน เพื่อดูคำอธิบายของส่วนต่างๆ

ตัวอย่างเช่น:

c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])

tf.sparse_segment_sum_with_num_segments(
    c, tf.constant([0, 1]), tf.constant([0, 0]), num_segments=3)
# => [[0 0 0 0]
#     [0 0 0 0]
#     [0 0 0 0]]

tf.sparse_segment_sum_with_num_segments(c,
                                        tf.constant([0, 1]),
                                        tf.constant([0, 2],
                                        num_segments=4))
# => [[ 1  2  3  4]
#     [ 0  0  0  0]
#     [-1 -2 -3 -4]
#     [ 0  0  0  0]]

ข้อโต้แย้ง:

  • ขอบเขต: วัตถุ ขอบเขต
  • ดัชนี: เทนเซอร์ 1-D มีอันดับเดียวกันกับ segment_ids
  • Segment_ids: เทนเซอร์ 1 มิติ ควรเรียงลำดับค่าและสามารถทำซ้ำได้
  • num_segments: ควรเท่ากับจำนวนรหัสส่วนที่แตกต่างกัน

ผลตอบแทน:

  • Output : มีรูปร่างเหมือนกับข้อมูล ยกเว้นมิติ 0 ซึ่งมีขนาด num_segments

ตัวสร้างและผู้ทำลาย

SparseSegmentSumWithNumSegments (const :: tensorflow::Scope & scope, :: tensorflow::Input data, :: tensorflow::Input indices, :: tensorflow::Input segment_ids, :: tensorflow::Input num_segments)

คุณลักษณะสาธารณะ

operation
output

งานสาธารณะ

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

คุณลักษณะสาธารณะ

การดำเนินการ

Operation operation

เอาท์พุท

::tensorflow::Output output

งานสาธารณะ

SparseSegmentSumWithNumSegments

 SparseSegmentSumWithNumSegments(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input data,
  ::tensorflow::Input indices,
  ::tensorflow::Input segment_ids,
  ::tensorflow::Input num_segments
)

โหนด

::tensorflow::Node * node() const 

ตัวดำเนินการ::tensorflow::อินพุต

 operator::tensorflow::Input() const 

ตัวดำเนินการ::tensorflow::เอาต์พุต

 operator::tensorflow::Output() const