テンソルフロー::作戦::ワンホット
#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) |
公共機能 | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
構造体 | |
---|---|
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