GatherND#

バージョン名: GatherND-8

カテゴリー: データ移動

簡単な説明: GatherND は、入力テンソルからスライスを収集して、インデックスで指定された形状のテンソルにします。

詳細な説明: GatherND は、indices によって data からスライスを収集し、indices で指定された形状のテンソルを形成します。

indices は、操作で data テンソルから要素またはスライスを収集するインデックスを持つタプルの K 次元整数テンソルまたは K-1 次元テンソルです。indices テンソル内の位置 i_0, ..., i_{K-2} は、長さが indices.shape[-1] に等しいインデックス indices[i_0, ..., i_{K-2}] を持つタプルに対応します。インデックスを含むこのタプルにより、次の式で説明されているように、操作は data テンソルからスライスまたは要素を収集し、それを出力の位置 i_0, ..., i_{K-2} に挿入します:

output[i_0, ..., i_{K-2},:,...,:] = data[indices[i_0, ..., i_{K-2}],:,...,:]

indices テンソルの最後の次元は、data テンソルのランクを超えてはなりません。つまり、indices.shape[-1] <= data.rank となります。

出力の形状は、indices.shape[-1] == data.rank - batch_dims の場合、indices.shape[:batch_dims] + indices.shape[batch_dims:-1] として計算され、そうでない場合は、indices.shape[:batch_dims] + list(indices.shape)[batch_dims:-1] + list(data.shape)[batch_dims + indices.shape[-1]:] となります。

属性:

  • batch_dims

    • 説明: batch_dims (b として示される) は、バッチを表す data テンソルと indices の先頭の次元数であり、GatherNDb+1 次元から収集を開始します。dataindices テンソルの最初の b 次元が等しい必要があります。

    • 値の範囲: [0; min(data.rank, indices.rank)) に属する整数

    • タイプ: int

    • デフォルト値: 0

    • 必須: いいえ

入力:

  • 1: T タイプの data テンソル。ランク 1 以上のテンソル。必須。

  • 2: T_IND タイプの indices テンソル。ランク 1 以上のテンソル。このテンソルのすべてのインデックスは [0, s-1] の範囲内にある必要があります。s は、このインデックスが適用される対応する次元です。必須。

出力:

  • 1: T タイプの収集された値を持つテンソル。

タイプ

  • T: サポートされるタイプ。

  • T_IND: サポートされている整数タイプ。

例 1 は、GatherNDdata テンソルの要素をどのように操作するかを示しています:

indices = [[0, 0], 
           [1, 0]] 
data    = [[1, 2], 
           [3, 4]] 
output = [1, 3]

例 2 は、GatherNDdata テンソルからのスライスをどのように操作するかを示しています:

indices = [[1], [0]] 
data    = [[1, 2], 
           [3, 4]] output = [[3, 4], [1, 2]]

例 3 は、indices テンソルに先行次元がある場合に GatherND がどのように動作するかを示しています:

indices = [[[1]], [[0]]] 
data = [[1, 2], 
      [3, 4]] 
output = [[[3, 4]], 
         [[1, 2]]]

例 4 は、GatherND がデフォルト以外の batch_dims 値の要素を収集する方法を示しています:

batch_dims = 1 
indices = [[1], <--- this is applied to the first batch 
       [0]] <--- this is applied to the second batch, shape = (2, 1) 
data = [[1, 2], <--- the first batch 
        [3, 4]] <--- the second batch, shape = (2, 2) 
output = [2, 3], shape = (2)

例 5 は、GatherND がデフォルト以外の batch_dims 値のスライスを収集する方法を示しています:

batch_dims = 1 
indices = [[1], <--- this is applied to the first batch 
           [0]] <--- this is applied to the second batch, shape = (2, 1) 
data    = [[[1, 2, 3, 4], [ 5, 6, 7, 8], [ 9, 10, 11, 12]] <--- the first batch 
           [[13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]] <--- the second batch, shape = (2, 3, 4) 
output = [[ 5, 6, 7, 8], [13, 14, 15, 16]], shape = (2, 4)

複雑な例 6 と 7 は、GatherND がデフォルト以外の batch_dims 値の先行次元を使用してスライスを収集する方法を示しています:

batch_dims = 2 
indices = [[[[1]], <--- this is applied to the first batch 
            [[0]], 
            [[2]]], 
           [[[0]], 
            [[2]], 
            [[2]]] <--- this is applied to the sixth batch ],
           shape = (2, 3, 1, 1) 
data    = [[[ 1, 2, 3, 4], <--- this is the first batch 
            [ 5, 6, 7, 8], 
            [ 9, 10, 11, 12]] 
           [[13, 14, 15, 16], 
            [17, 18, 19, 20], 
            [21, 22, 23, 24]] <--- this is the sixth batch
          ] <--- the second batch, shape = (2, 3, 4) 
output = [[[ 2], [ 5], [11]], [[13], [19], [23]]], shape = (2, 3, 1)
batch_dims = 3 
indices = [[[[1], 
             [0]], 
            [[3], 
             [2]]] 
            ], shape = (1, 2, 2, 1) 
data    = [[[[ 1 2 3 4], 
             [ 5 6 7 8]], 
            [[ 9 10 11 12], 
             [13 14 15 16]]] ], shape = (1, 2, 2, 4) 
output  = [[[ 2 5], 
            [12 15]] 
          ], shape = (1, 2, 2)
<layer id="1" type="GatherND" version="opset8"> 
    <data batch_dims="0" /> 
    <input> 
        <port id="0"> 
            <dim>1000</dim> 
            <dim>256</dim> 
            <dim>10</dim> 
            <dim>15</dim> 
        </port> 
        <port id="1"> 
            <dim>25</dim> 
            <dim>125</dim> 
            <dim>3</dim> 
        </port> 
    </input> 
    <output> 
        <port id="3"> 
            <dim>25</dim> 
            <dim>125</dim> 
            <dim>15</dim> 
        </port> 
    </output> 
</layer>
<layer id="1" type="GatherND" version="opset8"> 
    <data batch_dims="2" /> 
    <input> 
        <port id="0"> 
            <dim>30</dim> 
            <dim>2</dim> 
            <dim>100</dim> 
            <dim>35</dim> 
        </port> 
        <port id="1"> 
            <dim>30</dim> 
            <dim>2</dim> 
            <dim>3</dim> 
            <dim>1</dim> 
        </port> 
    </input> 
    <output> 
        <port id="3"> 
            <dim>30</dim> 
            <dim>2</dim> 
            <dim>3</dim> 
            <dim>35</dim> 
        </port> 
    </output> 
</layer>
<layer id="1" type="GatherND" version="opset8"> 
    <data batch_dims="3" /> 
    <input> 
        <port id="0"> 
            <dim>1</dim> 
            <dim>64</dim> 
            <dim>64</dim> 
            <dim>320</dim> 
        </port> 
        <port id="1"> 
            <dim>1</dim> 
            <dim>64</dim> 
            <dim>64</dim> 
            <dim>1</dim> 
            <dim>1</dim> 
        </port> 
    </input> 
    <output> 
        <port id="3"> 
            <dim>1</dim> 
            <dim>64</dim> 
            <dim>64</dim> 
            <dim>1</dim> 
        </port> 
    </output> 
</layer>