tensorflow:: ops:: OneHot
#include <array_ops.h>Zwraca tensor one-hot.
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 , to indeks wyjściowy będzie miał rangę N+1 . Nowa oś jest tworzona na axis wymiarowej (domyślnie: nowa oś jest dołączana na końcu).
Jeżeli indices są skalarem, to kształt wyjściowy będzie wektorem o długości depth .
Jeżeli indices są wektorem features długości, kształt wyjściowy będzie następujący:
features x depth if axis == -1 depth x features if axis == 0
Jeżeli indices są macierzą (partią) 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 zakresu
- indeksy: Tensor indeksów.
- głębokość: Skalar definiujący głębokość jednego gorącego wymiaru.
- on_value: Skalar definiujący wartość, która ma zostać wpisana do wyjścia, gdy
indices[j] = i. - off_value: Skalar definiujący wartość, którą należy wypełnić na wyjściu, gdy
indices[j] != i.
Atrybuty opcjonalne (patrz Attrs ):
- oś: Oś do wypełnienia (domyślnie: -1, nowa, najbardziej wewnętrzna oś).
Zwroty:
-
Output: Tensor one-hot.
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) |
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 | Opcjonalne ustawienia atrybutów 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::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Publiczne funkcje statyczne
Oś
Attrs Axis( int64 x )