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

#include <data_flow_ops.h>

แทรกค่าจากเทนเซอร์ data ลงในเทนเซอร์ตัวเดียว

สรุป

สร้างเทนเซอร์ที่ผสานเช่นนั้น

    merged[indices[m][i, ..., j], ...] = data[m][i, ..., j, ...]

ตัวอย่างเช่น ถ้าแต่ละ indices[m] เป็นสเกลาร์หรือเวกเตอร์ เราก็จะได้

    # Scalar indices:
    merged[indices[m], ...] = data[m][...]

    # Vector indices:
    merged[indices[m][i], ...] = data[m][i, ...]

แต่ละ data[i].shape ต้องเริ่มต้นด้วย indices[i].shape และส่วนที่เหลือของ data[i].shape จะต้องคงที่ wrt i นั่นคือเราต้องมี data[i].shape = indices[i].shape + constant ในแง่ของ constant นี้ รูปร่างเอาต์พุตคือ

merged.shape = [max(indices)] + constant

ค่าต่างๆ อาจรวมกันแบบขนาน ดังนั้นหากดัชนีปรากฏในทั้ง indices[m][i] และ indices[n][j] ผลลัพธ์อาจไม่ถูกต้อง สิ่งนี้แตกต่างจากตัวดำเนินการ DynamicStitch ปกติที่กำหนดลักษณะการทำงานในกรณีนั้น

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

    indices[0] = 6
    indices[1] = [4, 1]
    indices[2] = [[5, 2], [0, 3]]
    data[0] = [61, 62]
    data[1] = [[41, 42], [11, 12]]
    data[2] = [[[51, 52], [21, 22]], [[1, 2], [31, 32]]]
    merged = [[1, 2], [11, 12], [21, 22], [31, 32], [41, 42],
              [51, 52], [61, 62]]

วิธีการนี้สามารถใช้เพื่อผสานพาร์ติชันที่สร้างโดย dynamic_partition ดังที่แสดงในตัวอย่างต่อไปนี้:

    # Apply function (increments x_i) on elements for which a certain condition
    # apply (x_i != -1 in this example).
    x=tf.constant([0.1, -1., 5.2, 4.3, -1., 7.4])
    condition_mask=tf.not_equal(x,tf.constant(-1.))
    partitioned_data = tf.dynamic_partition(
        x, tf.cast(condition_mask, tf.int32) , 2)
    partitioned_data[1] = partitioned_data[1] + 1.0
    condition_indices = tf.dynamic_partition(
        tf.range(tf.shape(x)[0]), tf.cast(condition_mask, tf.int32) , 2)
    x = tf.dynamic_stitch(condition_indices, partitioned_data)
    # Here x=[1.1, -1., 6.2, 5.3, -1, 8.4], the -1. values remain
    # unchanged.

ข้อโต้แย้ง:

ผลตอบแทน:

  • Output : เทนเซอร์ที่ผสาน

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

ParallelDynamicStitch (const :: tensorflow::Scope & scope, :: tensorflow::InputList indices, :: tensorflow::InputList data)

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

merged
operation

งานสาธารณะ

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

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

ผสาน

::tensorflow::Output merged

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

Operation operation

งานสาธารณะ

ParallelDynamicStitch

 ParallelDynamicStitch(
  const ::tensorflow::Scope & scope,
  ::tensorflow::InputList indices,
  ::tensorflow::InputList data
)

โหนด

::tensorflow::Node * node() const 

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

 operator::tensorflow::Input() const 

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

 operator::tensorflow::Output() const