przepływ tensorowy:: ops:: OneHot
#include <array_ops.h>
Zwraca jeden gorący tensor.
Streszczenie
Lokalizacje reprezentowane przez indeksy w indices
przyjmują wartość on_value
, podczas gdy wszystkie inne lokalizacje przyjmują wartość off_value
.
Jeśli indices
wejściowe mają rangę N
, wyjście będzie miało rangę N+1
. Nowa oś tworzona jest na axis
wymiaru (domyślnie: nowa oś jest dodawana na końcu).
Jeśli indices
są skalarami, kształtem wyjściowym będzie wektor długości depth
.
Jeżeli indices
są wektorami features
długości, to wynik będzie następujący:
features x depth if axis == -1
depth x features if axis == 0
Jeśli indices
jest macierz (partia) o kształcie [batch, features]
, kształt wyjściowy będzie następujący:
batch x features x depth if axis == -1
batch x depth x features if axis == 1
depth x batch x features if axis == 0
Przykłady
Załóżmy, że
indices = [0, 2, -1, 1]
depth = 3
on_value = 5.0
off_value = 0.0
axis = -1
Następnie wynik wynosi [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)
Załóżmy, że
indices = [0, 2, -1, 1]
depth = 3
on_value = 0.0
off_value = 3.0
axis = 0
Następnie wynik wynosi [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)
Załóżmy, że
indices = [[0, 2], [1, -1]]
depth = 3
on_value = 1.0
off_value = 0.0
axis = -1
Następnie wynik wynosi [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)
]
Argumenty:
- zakres: Obiekt Scope
- indeksy: Tensor indeksów.
- głębokość: Skalar określający głębokość jednego gorącego wymiaru.
- on_value: Skalar definiujący wartość do wypełnienia, gdy
indices[j] = i
. - off_value: Skalar definiujący wartość wypełnianą na wyjściu, gdy
indices[j] != i
.
Opcjonalne atrybuty (patrz Attrs
):
- oś: Oś do wypełnienia (domyślnie: -1, nowa oś najbardziej wewnętrzna).
Zwroty:
-
Output
: Tensor jednego gorącego.
Konstruktory i destruktory | |
---|---|
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) |
Funkcje publiczne | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Struktury | |
---|---|
tensorflow:: ops:: OneHot:: Atrybuty | Opcjonalne moduły ustawiające atrybuty dla OneHot . |
Atrybuty publiczne
działanie
Operation operation
wyjście
::tensorflow::Output output
Funkcje publiczne
OneHot
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value
)
OneHot
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value,
const OneHot::Attrs & attrs
)
węzeł
::tensorflow::Node * node() const
operator::tensorflow::Wejście
operator::tensorflow::Input() const
operator::tensorflow::Wyjście
operator::tensorflow::Output() const
Publiczne funkcje statyczne
Oś
Attrs Axis(
int64 x
)