テンソルフロー::作戦::深さから空間まで

#include <array_ops.h>

T 型のテンソルのDepthToSpace

まとめ

データを深度から空間データのブロックに再配置します。これは、SpaceToDepth の逆変換です。より具体的には、この操作は、 depth次元の値が空間ブロックでheightおよびwidth次元に移動される入力テンソルのコピーを出力します。 attr block_size入力ブロック サイズとデータの移動方法を示します。

  • 深さからのサイズblock_size * block_sizeのデータのチャンクは、サイズblock_size x block_sizeの重複しないブロックに再配置されます。
  • 出力テンソルの幅はinput_depth * block_sizeですが、高さはinput_height * block_sizeです。
  • 出力イメージの各ブロック内の Y、X 座標は、入力チャネル インデックスの高次成分によって決定されます。
  • 入力テンソルの深さは、 block_size * block_sizeで割り切れる必要があります。

data_format属性は、次のオプションを使用して入力テンソルと出力テンソルのレイアウトを指定します: "NHWC": [ batch, height, width, channels ] "NCHW": [ batch, channels, height, width ] "NCHW_VECT_C": qint8 [ batch, channels / 4, height, width, 4 ]

この操作を 6-D Tensorの変換と考えると便利です。たとえば、data_format = NHWC の場合、入力テンソルの各要素は 6 つの座標を介して指定でき、メモリ レイアウトの重要性の降順で次のように並べられます: n,iY,iX,bY,bX,oC (ここで、n=バッチ インデックス、iX、iY は X を意味します)または入力画像内の Y 座標、bX、bY は出力ブロック内の座標、oC は出力チャネルを意味します)。出力は、入力を次のレイアウトに転置したものになります: n,iY,bY,iX,bX,oC

この操作は、たとえばプールする代わりに、畳み込み間のアクティベーションのサイズを変更する場合に役立ちます (ただし、すべてのデータは保持します)。純粋に畳み込みモデルをトレーニングする場合にも役立ちます。

たとえば、shape [1, 1, 1, 4]の入力、 data_format = "NHWC" および block_size = 2 の場合、次のようになります。

x = [[[[1, 2, 3, 4]]]]

  

This operation will output a tensor of shape [1, 2, 2, 1]:

   [[[[1], [2]],
     [[3], [4]]]]

ここで、入力には 1 のバッチがあり、各バッチ要素の形状は[1, 1, 4]で、対応する出力には 2x2 要素があり、深さは 1 チャネルになります (1 = 4 / (block_size * block_size) )。出力要素の形状は[2, 2, 1]です。

より深い深さの入力テンソルの場合、ここでは[1, 1, 1, 12]の形状になります。

x = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]

この操作は、ブロック サイズ 2 の場合、次の形状[1, 2, 2, 3]のテンソルを返します。

   [[[[1, 2, 3], [4, 5, 6]],
     [[7, 8, 9], [10, 11, 12]]]]

  

Similarly, for the following input of shape [1 2 2 4], and a block size of 2:

x =  [[[[1, 2, 3, 4],
       [5, 6, 7, 8]],
      [[9, 10, 11, 12],
       [13, 14, 15, 16]]]]

演算子は、次の形状[1 4 4 1]のテンソルを返します。

x = [[[ [1],   [2],  [5],  [6]],
      [ [3],   [4],  [7],  [8]],
      [ [9],  [10], [13],  [14]],
      [ [11], [12], [15],  [16]]]]

  

Arguments:

  • scope: A Scope object
  • block_size: The size of the spatial block, same as in Space2Depth.

Returns:

Constructors and Destructors

DepthToSpace(const ::tensorflow::Scope & scope, ::tensorflow::Input input, int64 block_size)
DepthToSpace(const ::tensorflow::Scope & scope, ::tensorflow::Input input, int64 block_size, const DepthToSpace::Attrs & attrs)

Public attributes

operation
output

Public functions

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

Public static functions

DataFormat(StringPiece x)

Structs

tensorflow::ops::DepthToSpace::Attrs

Optional attribute setters for DepthToSpace.

Public attributes

operation

Operation operation

出力

::tensorflow::Output output

公共機能

深さから空間まで

 DepthToSpace(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  int64 block_size
)

深さから空間まで

 DepthToSpace(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  int64 block_size,
  const DepthToSpace::Attrs & attrs
)

ノード

::tensorflow::Node * node() const 

演算子::tensorflow::入力

 operator::tensorflow::Input() const 

演算子::tensorflow::出力

 operator::tensorflow::Output() const 

パブリック静的関数

データ形式

Attrs DataFormat(
  StringPiece x
)