aliran tensor:: operasi:: Satu Panas
#include <array_ops.h>
Mengembalikan tensor satu-panas.
Ringkasan
Lokasi yang diwakili oleh indeks dalam indices
mengambil nilai on_value
, sementara semua lokasi lainnya mengambil nilai off_value
.
Jika indices
input adalah peringkat N
, output akan memiliki peringkat N+1
, Sumbu baru dibuat pada axis
dimensi (default: sumbu baru ditambahkan di akhir).
Jika indices
adalah skalar, bentuk keluarannya akan menjadi vektor dengan panjang depth
.
Jika indices
adalah vektor dengan features
panjang, bentuk keluarannya adalah:
features x depth if axis == -1
depth x features if axis == 0
Jika indices
adalah matriks (batch) dengan bentuk [batch, features]
, bentuk keluarannya adalah:
batch x features x depth if axis == -1
batch x depth x features if axis == 1
depth x batch x features if axis == 0
Contoh
Misalkan itu
indices = [0, 2, -1, 1]
depth = 3
on_value = 5.0
off_value = 0.0
axis = -1
Maka outputnya adalah [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)
Misalkan itu
indices = [0, 2, -1, 1]
depth = 3
on_value = 0.0
off_value = 3.0
axis = 0
Maka outputnya adalah [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)
Misalkan itu
indices = [[0, 2], [1, -1]]
depth = 3
on_value = 1.0
off_value = 0.0
axis = -1
Maka outputnya adalah [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)
]
Argumen:
- ruang lingkup: Objek Lingkup
- indeks: Tensor indeks.
- kedalaman: Skalar yang menentukan kedalaman satu dimensi panas.
- on_value: Skalar yang menentukan nilai untuk mengisi output ketika
indices[j] = i
. - off_value: Skalar yang menentukan nilai untuk mengisi output ketika
indices[j] != i
.
Atribut opsional (lihat Attrs
):
- sumbu: Sumbu yang akan diisi (default: -1, sumbu paling dalam yang baru).
Pengembalian:
-
Output
: Tensor satu-panas.
Konstruktor dan Destruktor | |
---|---|
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) |
Fungsi publik | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Struktur | |
---|---|
tensorflow:: ops:: OneHot:: Attrs | Penyetel atribut opsional untuk OneHot . |
Atribut publik
operasi
Operation operation
keluaran
::tensorflow::Output output
Fungsi publik
Satu Panas
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value
)
Satu Panas
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value,
const OneHot::Attrs & attrs
)
simpul
::tensorflow::Node * node() const
operator::tensorflow::Masukan
operator::tensorflow::Input() const
operator::tensorflow::Keluaran
operator::tensorflow::Output() const
Fungsi statis publik
Sumbu
Attrs Axis(
int64 x
)