เทนเซอร์โฟลว์:: ปฏิบัติการ:: รวบรวมNd
#include <array_ops.h> รวบรวม ชิ้นส่วนจาก params ลงใน เทนเซอร์ ที่มีรูปร่างที่ระบุโดย indices
สรุป
indices เป็นเทนเซอร์จำนวนเต็ม K-มิติ ซึ่งคิดว่าดีที่สุดในฐานะเทนเซอร์มิติ (K-1) ของดัชนีใน params โดยที่แต่ละองค์ประกอบจะกำหนดส่วนของ params :
output[\\(i_0, ..., i_{K-2}\\)] = params[indices[\\(i_0, ..., i_{K-2}\\)]] ในขณะที่ indices tf.gather กำหนดส่วนต่างๆ ลงในมิติ axis ของ params ใน tf.gather_nd indices จะกำหนดส่วนต่างๆ ให้เป็นมิติ N แรกของ params โดยที่ N = indices.shape[-1]
มิติสุดท้ายของ indices สามารถอยู่ในอันดับของ params ได้มากที่สุด :
indices.shape[-1] <= params.rank
มิติสุดท้ายของ indices สอดคล้องกับองค์ประกอบ (ถ้า indices.shape[-1] == params.rank ) หรือชิ้น (ถ้า indices.shape[-1] < params.rank ) ตามมิติ indices.shape[-1] ของ params . เทนเซอร์เอาท์พุตมีรูปร่าง
indices.shape[:-1] + params.shape[indices.shape[-1]:]
โปรดทราบว่าบน CPU หากพบดัชนีนอกขอบเขต ข้อผิดพลาดจะถูกส่งกลับ บน GPU หากพบดัชนีนอกขอบเขต 0 จะถูกเก็บไว้ในค่าเอาต์พุตที่สอดคล้องกัน
ตัวอย่างบางส่วนด้านล่าง
การจัดทำดัชนีอย่างง่ายในเมทริกซ์:
indices = [[0, 0], [1, 1]]
params = [['a', 'b'], ['c', 'd']]
output = ['a', 'd']การจัดทำดัชนีชิ้นเป็นเมทริกซ์:
indices = [[1], [0]]
params = [['a', 'b'], ['c', 'd']]
output = [['c', 'd'], ['a', 'b']]การจัดทำดัชนีเป็น 3 เทนเซอร์:
indices = [[1]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = [[['a1', 'b1'], ['c1', 'd1']]] indices = [[0, 1], [1, 0]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = [['c0', 'd0'], ['a1', 'b1']] indices = [[0, 0, 1], [1, 0, 1]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = ['b0', 'b1']การจัดทำดัชนีแบบแบตช์เป็นเมทริกซ์:
indices = [[[0, 0]], [[0, 1]]]
params = [['a', 'b'], ['c', 'd']]
output = [['a'], ['b']]การจัดทำดัชนีชิ้นแบบเป็นชุดลงในเมทริกซ์:
indices = [[[1]], [[0]]]
params = [['a', 'b'], ['c', 'd']]
output = [[['c', 'd']], [['a', 'b']]]การจัดทำดัชนีแบบแบตช์เป็น 3 เทนเซอร์:
indices = [[[1]], [[0]]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = [[[['a1', 'b1'], ['c1', 'd1']]],
[[['a0', 'b0'], ['c0', 'd0']]]] indices = [[[0, 1], [1, 0]], [[0, 0], [1, 1]]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = [[['c0', 'd0'], ['a1', 'b1']],
[['a0', 'b0'], ['c1', 'd1']]] indices = [[[0, 0, 1], [1, 0, 1]], [[0, 1, 1], [1, 1, 0]]]
params = [[['a0', 'b0'], ['c0', 'd0']],
[['a1', 'b1'], ['c1', 'd1']]]
output = [['b0', 'b1'], ['d0', 'c1']] ดูเพิ่มเติมที่ tf.gather และ tf.batch_gather
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- params: เทนเซอร์ที่ใช้รวบรวมค่าต่างๆ
- ดัชนี: ดัชนีเทนเซอร์
ผลตอบแทน:
-
Output: ค่าจากparamsที่รวบรวมจากดัชนีที่กำหนดโดยindicesโดยมีรูปร่างindices.shape[:-1] + params.shape[indices.shape[-1]:]
ตัวสร้างและผู้ทำลาย | |
|---|---|
GatherNd (const :: tensorflow::Scope & scope, :: tensorflow::Input params, :: tensorflow::Input indices) |
คุณลักษณะสาธารณะ | |
|---|---|
operation | |
output | |
งานสาธารณะ | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
คุณลักษณะสาธารณะ
การดำเนินการ
Operation operation
เอาท์พุท
::tensorflow::Output output
งานสาธารณะ
รวบรวมNd
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
โหนด
::tensorflow::Node * node() const
ตัวดำเนินการ::tensorflow::อินพุต
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const