テンソルフロー::作戦::ワンホット

#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 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)
  ]

引数:

  • スコープ:スコープオブジェクト
  • Indexes: インデックスのテンソル。
  • 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 

演算子::tensorflow::入力

 operator::tensorflow::Input() const 

演算子::tensorflow::出力

 operator::tensorflow::Output() const 

パブリック静的関数

Attrs Axis(
  int64 x
)