tensorflow::ops::GatherNd
#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}\\)]] ในขณะที่ใน tf.gather indices จะกำหนดส่วนย่อยในมิติแรกของ 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
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- พารามิเตอร์: เทนเซอร์ที่จะใช้รวบรวมค่าต่างๆ
- ดัชนี: เทนเซอร์ดัชนี
การส่งคืนสินค้า:
-
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
หน้าที่สาธารณะ
รวบรวมและ
GatherNd( const ::tensorflow::Scope & scope, ::tensorflow::Input params, ::tensorflow::Input indices )
โหนด
::tensorflow::Node * node() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::อินพุต
operator::tensorflow::Input() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::เอาต์พุต
operator::tensorflow::Output() const