flux tensoriel : : opérations : : Unchaud
#include <array_ops.h>Renvoie un tenseur one-hot.
Résumé
Les emplacements représentés par des indices dans indices prennent la valeur on_value , tandis que tous les autres emplacements prennent la valeur off_value .
Si les indices d'entrée sont de rang N , la sortie aura le rang N+1 , Le nouvel axe est créé au niveau de axis de dimension (par défaut : le nouvel axe est ajouté à la fin).
Si indices est un scalaire, la forme de sortie sera un vecteur de longueur depth .
Si indices est un vecteur de features de longueur, la forme de sortie sera :
features x depth if axis == -1 depth x features if axis == 0
Si indices est une matrice (batch) avec la forme [batch, features] , la forme de sortie sera :
batch x features x depth if axis == -1 batch x depth x features if axis == 1 depth x batch x features if axis == 0
Exemples
Supposons que
indices = [0, 2, -1, 1] depth = 3 on_value = 5.0 off_value = 0.0 axis = -1
La sortie est alors [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)
Supposons que
indices = [0, 2, -1, 1] depth = 3 on_value = 0.0 off_value = 3.0 axis = 0
La sortie est alors [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)
Supposons que
indices = [[0, 2], [1, -1]] depth = 3 on_value = 1.0 off_value = 0.0 axis = -1
La sortie est alors [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)
]Arguments :
- scope : un objet Scope
- indices : un tenseur d'indices.
- profondeur : un scalaire définissant la profondeur de la dimension chaude.
- on_value : un scalaire définissant la valeur à remplir en sortie lorsque
indices[j] = i. - off_value : un scalaire définissant la valeur à remplir en sortie lorsque
indices[j] != i.
Attributs facultatifs (voir Attrs ) :
- axis : L'axe à remplir (par défaut : -1, un nouvel axe le plus à l'intérieur).
Retours :
-
Output: Le tenseur one-hot.
Constructeurs et Destructeurs | |
|---|---|
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) |
Attributs publics | |
|---|---|
operation | |
output | |
Fonctions publiques | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Fonctions statiques publiques | |
|---|---|
Axis (int64 x) | |
Structures | |
|---|---|
| tensorflow :: ops :: OneHot :: Attrs | Setters d'attributs facultatifs pour OneHot . |
Attributs publics
opération
Operation operation
sortir
::tensorflow::Output output
Fonctions publiques
Unchaud
OneHot( const ::tensorflow::Scope & scope, ::tensorflow::Input indices, ::tensorflow::Input depth, ::tensorflow::Input on_value, ::tensorflow::Input off_value )
Unchaud
OneHot( const ::tensorflow::Scope & scope, ::tensorflow::Input indices, ::tensorflow::Input depth, ::tensorflow::Input on_value, ::tensorflow::Input off_value, const OneHot::Attrs & attrs )
nœud
::tensorflow::Node * node() const
opérateur :: tensorflow :: Entrée
operator::tensorflow::Input() const
opérateur :: tensorflow :: Sortie
operator::tensorflow::Output() const
Fonctions statiques publiques
Axe
Attrs Axis( int64 x )