ExtractImagePatches#

バージョン名: ExtractImagePatches-3

カテゴリー: データ移動

簡単な説明: ExtractImagePatches 操作は、畳み込みを適用するかのように、入力テンソルからパッチを収集します。抽出されたすべてのパッチは、出力の深さ次元にスタックされます。

詳細な説明:

ExtractImagePatches 操作は、入力イメージ内で strides 離れた形状 sizes のパッチを抽出します。出力要素は、拡張畳み込みのように、rate 引数で指定された間隔で入力から取得されます。

結果は、“深さ” 次元でベクトル化されたサイズ size[0] * size[1] * depth の画像パッチを含む 4D テンソルです。

“auto_pad” 属性は各パッチのサイズには影響せず、抽出されるパッチの数を決定します。

属性

  • sizes

    • 説明: sizes は、抽出されたパッチのサイズ [size_rows, size_cols] です。

    • 値の範囲: 負でない整数

    • タイプ: int[]

    • 必須: はい

  • strides

    • 説明: strides は、入力テンソル内の 2 つの連続するパッチの中心間の距離 [stride_rows, stride_cols] です。

    • 値の範囲: 負でない整数

    • タイプ: int[]

    • 必須: はい

  • rates

    • 説明: rates は入力ストライド [rate_rows, rate_cols] で、入力内で 2 つの連続するパッチサンプルがどのくらい離れているかを指定します。patch_sizes_eff = patch_sizes + (patch_sizes - 1) * (rates - 1) を使用してパッチを抽出し、その後、レート係数で空間的にサブサンプリングするのと同じです。これは、拡張された (別名 Atrous) 畳み込みのレートに相当します。

    • 値の範囲: 負でない整数

    • タイプ: int[]

    • 必須: はい

  • auto_pad

    • 説明: auto_pad パディングの計算方法。設定可能な値:

      • same_upper (same_lower) 出力サイズと一致するように入力にゼロが埋め込まれます。パディング値が奇数の場合、追加のパディングが最後 (先頭) に追加されます。

      • valid - パディングを使用しません。

    • タイプ: string

    • 必須: はい

入力

  • 1: data 形状 [batch, depth, in_rows, in_cols]T タイプの 4-D テンソル。必須。

出力

  • 1: data テンソルと等しいタイプを持つ形状 [batch, size[0] * size[1] * depth, out_rows, out_cols] の 4-D テンソル。out_rowsout_cols は出力パッチの次元であることに注意してください。

タイプ

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

<layer type="ExtractImagePatches" ...> 
    <data sizes="3,3" strides="5,5" rates="1,1" auto_pad="valid"/> 
    <input> 
        <port id="0"> 
            <dim>64</dim> 
            <dim>3</dim> 
            <dim>10</dim> 
            <dim>10</dim> 
        </port> 
    </input> 
    <output> 
        <port id="1" precision="f32"> 
            <dim>64</dim> 
            <dim>27</dim> 
            <dim>2</dim> 
            <dim>2</dim> 
        </port> 
    </output> 
</layer>

画像は、1 ~ 100 の数字を含む 1 x 1 x 10 x 10 の配列です。出力パッチをマークするには、記号 x を使用します。

  1. sizes="3,3", strides="5,5", rates="1,1", auto_pad="valid"

    \[\begin{split}\begin{bmatrix} x & x & x & 4 & 5 & x & x & x & 9 & 10 \\ x & x & x & 14 & 15 & x & x & x & 19 & 20 \\ x & x & x & 24 & 25 & x & x & x & 29 & 30 \\ 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 \\ 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 \\ x & x & x & 54 & 55 & x & x & x & 59 & 60 \\ x & x & x & 64 & 65 & x & x & x & 69 & 70 \\ x & x & x & 74 & 75 & x & x & x & 79 & 80 \\ 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ 91 & 92 & 93 & 94 & 95 & 96 & 79 & 98 & 99 & 100 \end{bmatrix}\end{split}\]

    出力:

    [[[[ 1 6] 
       [51 56]] 
    
      [[ 2 7] 
       [52 57]]
     
      [[ 3 8] 
       [53 58]] 
    
      [[11 16] 
       [61 66]] 
    
      [[12 17] 
       [62 67]] 
    
      [[13 18] 
       [63 68]] 
    
      [[21 26] 
       [71 76]] 
    
      [[22 27] 
       [72 77]] 
    
      [[23 28] 
       [73 78]]]]

    出力形状: [1, 9, 2, 2]

  2. sizes="4,4", strides="8,8", rates="1,1", auto_pad="valid"

    \[\begin{split}\begin{bmatrix} x & x & x & x & 5 & 6 & 7 & 8 & 9 & 10 \\ x & x & x & x & 15 & 16 & 17 & 18 & 19 & 20 \\ x & x & x & x & 25 & 26 & 27 & 28 & 29 & 30 \\ x & x & x & x & 35 & 36 & 37 & 38 & 39 & 40 \\ 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 \\ 51 & 52 & 53 & 54 & 55 & 56 & 57 & 58 & 59 & 60 \\ 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 \\ 71 & 72 & 73 & 74 & 75 & 76 & 77 & 78 & 79 & 80 \\ 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ 91 & 92 & 93 & 94 & 95 & 96 & 79 & 98 & 99 & 100 \end{bmatrix}\end{split}\]

    出力:

    [[[[ 1]]
      [[ 2]] 
      [[ 3]] 
      [[ 4]] 
      [[11]] 
      [[12]] 
      [[13]] 
      [[14]] 
      [[21]] 
      [[22]] 
      [[23]] 
      [[24]] 
      [[31]] 
      [[32]] 
      [[33]] 
      [[34]]]]

    出力形状: [1, 16, 1, 1]

  3. sizes="4,4", strides="9,9", rates="1,1", auto_pad="same_upper"

    \[\begin{split}\begin{bmatrix} x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x\\ x & x & x & x & 4 & 5 & 6 & 7 & 8 & x & x & x & x\\ x & x & x & x & 14 & 15 & 16 & 17 & 18 & x & x & x & x\\ x & x & x & x & 24 & 25 & 26 & 27 & 28 & x & x & x & x\\ 0 & 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 & 0 & 0\\ 0 & 41 & 42 & 43 & 44 & 45 & 46 & 47 & 48 & 49 & 50 & 0 & 0\\ 0 & 51 & 52 & 53 & 54 & 55 & 56 & 57 & 58 & 59 & 60 & 0 & 0\\ 0 & 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 & 0 & 0\\ 0 & 71 & 72 & 73 & 74 & 75 & 76 & 77 & 78 & 79 & 80 & 0 & 0\\ x & x & x & x & 84 & 85 & 86 & 87 & 88 & x & x & x & x\\ x & x & x & x & 94 & 95 & 96 & 79 & 98 & x & x & x & x\\ x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x\\ x & x & x & x & 0 & 0 & 0 & 0 & 0 & x & x & x & x \end{bmatrix}\end{split}\]

    出力:

    [[[[ 0 0] 
       [ 0 89]] 
      [[ 0 0] 
       [ 81 90]] 
      [[ 0 0] 
       [ 82 0]] 
      [[ 0 0] 
       [ 83 0]] 
      [[ 0 9] 
       [ 0 99]] 
      [[ 1 10] 
       [ 91 100]] 
      [[ 2 0] 
       [ 92 0]] 
      [[ 3 0] 
       [ 93 0]] 
      [[ 0 19] 
       [ 0 0]] 
      [[ 11 20] 
       [ 0 0]] 
      [[ 12 0] 
       [ 0 0]] 
      [[ 13 0] 
       [ 0 0]] 
      [[ 0 29] 
       [ 0 0]] 
      [[ 21 30] 
       [ 0 0]] 
      [[ 22 0] 
       [ 0 0]] 
      [[ 23 0] 
       [ 0 0]]]]

    出力形状: [1, 16, 2, 2]

  4. sizes="3,3", strides="5,5", rates="2,2", auto_pad="valid"

    ここでは、パッチを区別するため記号 xyzk を使用します:

    \[\begin{split}\begin{bmatrix} x & 2 & x & 4 & x & y & 7 & y & 9 & y \\ 11 & 12 & 13 & 14 & 15 & 16 & 17 & 18 & 19 & 20 \\ x & 22 & x & 24 & x & y & 27 & y & 29 & y \\ 31 & 32 & 33 & 34 & 35 & 36 & 37 & 38 & 39 & 40 \\ x & 42 & x & 44 & x & y & 47 & y & 49 & y \\ z & 52 & z & 54 & z & k & 57 & k & 59 & k \\ 61 & 62 & 63 & 64 & 65 & 66 & 67 & 68 & 69 & 70 \\ z & 72 & z & 74 & z & k & 77 & k & 79 & k \\ 81 & 82 & 83 & 84 & 85 & 86 & 87 & 88 & 89 & 90 \\ z & 92 & z & 94 & z & k & 79 & k & 99 & k \end{bmatrix}\end{split}\]

    出力:

    [[[[ 1 6] 
       [ 51 56]] 
      [[ 3 8] 
       [ 53 58]] 
      [[ 5 10] 
       [ 55 60]] 
      [[ 21 26] 
       [ 71 76]] 
      [[ 23 28] 
       [ 73 78]] 
      [[ 25 30] 
       [ 75 80]] 
      [[ 41 46] 
       [ 91 96]] 
      [[ 43 48] 
       [ 93 98]] 
      [[ 45 50] 
       [ 95 100]]]]

    output_shape: [1, 9, 2, 2]

  5. sizes="2,2", strides="3,3", rates="1,1", auto_pad="valid"

    画像は 2 つの特徴マップを含む 1 x 2 x 5 x 5 の配列であり、座標 0 の特徴マップには範囲 [1, 25] の数値が含まれ、座標 1 の特徴マップには範囲内の数値が含まれます

    \[\begin{split}\begin{bmatrix} x & x & 3 & x & x\\ x & x & 8 & x & x\\ 11 & 12 & 13 & 14 & 15\\ x & x & 18 & x & x\\ x & x & 23 & x & x \end{bmatrix}\\ \begin{bmatrix} x & x & 28 & x & x\\ x & x & 33 & x & x\\ 36 & 37 & 38 & 39 & 40\\ x & x & 43 & x & x\\ x & x & 48 & x & x \end{bmatrix}\end{split}\]

    出力:

    [[[[ 1 4] 
       [16 19]] 
      [[26 29] 
       [41 44]] 
      [[ 2 5] 
       [17 20]] 
      [[27 30] 
       [42 45]] 
      [[ 6 9] 
       [21 24]] 
      [[31 34] 
       [46 49]] 
      [[ 7 10] 
       [22 25]] 
      [[32 35] 
       [47 50]]]]

    出力形状: [1, 8, 2, 2]