tensorflow:: ops:: OneHot

#include <array_ops.h>

ワンホットエンソルを返します。

まとめ

indices内のインデックスで表される場所はon_value値を取り、その他のすべての場所はoff_value値を取ります。

入力indicesのランクがNの場合、出力のランクはN+1になります。新しい軸は次元axisに作成されます (デフォルト: 新しい軸は末尾に追加されます)。

indicesがスカラーの場合、出力形状は長さdepthのベクトルになります。

indices長さfeaturesのベクトルである場合、出力形状は次のようになります。

  features x depth if axis == -1
  depth x features if axis == 0

indices形状[batch, features]の行列(batch)である場合、出力形状は次のようになります。

  batch x features x depth if axis == -1
  batch x depth x features if axis == 1
  depth x batch x features if axis == 0

例

仮に

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 5.0
  off_value = 0.0
  axis = -1

すると出力は[4 x 3]になります。

output =
  [5.0 0.0 0.0]  // one_hot(0)
  [0.0 0.0 5.0]  // one_hot(2)
  [0.0 0.0 0.0]  // one_hot(-1)
  [0.0 5.0 0.0]  // one_hot(1)

仮に

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 0.0
  off_value = 3.0
  axis = 0

すると出力は[3 x 4]になります。

output =
  [0.0 3.0 3.0 3.0]
  [3.0 3.0 3.0 0.0]
  [3.0 3.0 3.0 3.0]
  [3.0 0.0 3.0 3.0]
//  ^                one_hot(0)
//      ^            one_hot(2)
//          ^        one_hot(-1)
//              ^    one_hot(1)

仮に

  indices = [[0, 2], [1, -1]]
  depth = 3
  on_value = 1.0
  off_value = 0.0
  axis = -1

すると出力は[2 x 2 x 3]になります。

output =
  [
    [1.0, 0.0, 0.0]  // one_hot(0)
    [0.0, 0.0, 1.0]  // one_hot(2)
  ][
    [0.0, 1.0, 0.0]  // one_hot(1)
    [0.0, 0.0, 0.0]  // one_hot(-1)
  ]

議論:

  • スコープ:スコープオブジェクト
  • インデックス: インデックスのテンソル。
  • depth: 1 つのホット ディメンションの深さを定義するスカラー値。
  • on_value: indices[j] = iのときに出力に埋める値を定義するスカラー。
  • off_value: indices[j] != iの場合に出力に埋める値を定義するスカラー。

オプション属性( Attrs参照):

  • axis: 塗りつぶす軸(デフォルト:-1、最も内側の新しい軸)。

返品:

  • Output :ワンホットテンソル。

コンストラクターとデストラクタ

OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value)
OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value, const OneHot::Attrs & attrs)

公開属性

operation
output

公的機能

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

パブリック静的関数

Axis (int64 x)

構造

tensorflow:: ops:: OneHot:: Attrs

OneHotのオプション属性設定子。

公開属性

手術

Operation operation

出力

::tensorflow::Output output

公的機能

ワンホット

 OneHot(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input indices,
  ::tensorflow::Input depth,
  ::tensorflow::Input on_value,
  ::tensorflow::Input off_value
)

ワンホット

 OneHot(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input indices,
  ::tensorflow::Input depth,
  ::tensorflow::Input on_value,
  ::tensorflow::Input off_value,
  const OneHot::Attrs & attrs
)

ノード

::tensorflow::Node * node() const 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const 

パブリック静的関数

軸

Attrs Axis(
  int64 x
)