tensorflow :: 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
, wynik będzie miał rangę N+1
, Nowa oś jest tworzona na axis
wymiaru (domyślnie: nowa oś jest dołączana na końcu).
Jeśli indices
są skalarami, kształtem wyjściowym będzie wektor depth
długości.
Jeśli indices
są wektorem features
długości, wynikowy kształt będzie wyglądał następująco:
features x depth if axis == -1 depth x features if axis == 0
Jeśli indices
to macierz (partia) o kształcie [batch, features]
, wynikowy kształt będzie wyglądał następująco:
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
Wtedy wynik to [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
Wtedy wynik to [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
Wtedy wynik to [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ść: wartość skalarna określająca głębokość jednego gorącego wymiaru.
- on_value: Skalar definiujący wartość wypełniającą dane wyjściowe, gdy
indices[j] = i
. - off_value: Skalar definiujący wartość wypełniającą dane wyjściowe, gdy
indices[j] != i
.
Atrybuty opcjonalne (patrz Attrs
):
- oś: oś do wypełnienia (domyślnie: -1, nowa najbardziej wewnętrzna oś).
Zwroty:
-
Output
: jeden gorący tensor.
Konstruktorzy i niszczyciele | |
---|---|
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) |
Atrybuty publiczne | |
---|---|
operation | |
output |
Funkcje publiczne | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Publiczne funkcje statyczne | |
---|---|
Axis (int64 x) |
Struktury | |
---|---|
tensorflow :: ops :: OneHot :: Attrs |
Atrybuty publiczne
operacja
Operation operation
wynik
::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 :: Input
operator::tensorflow::Input() const
operator :: tensorflow :: Output
operator::tensorflow::Output() const
Publiczne funkcje statyczne
Oś
Attrs Axis( int64 x )