tensorflow::ops::OneHot
#include <array_ops.h>Renvoie un tenseur one-hot.
Résumé
Les emplacements représentés par les 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 un rang N+1 . Le nouvel axe est créé au niveau 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 longueur features , la forme de sortie sera :
features x depth if axis == -1 depth x features if axis == 0
Si indices est une matrice (lot) de 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
Le résultat 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
Le résultat 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
Le résultat 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 :
- portée : un objet Scope
- indices : Un tenseur d'indices.
- profondeur : un scalaire définissant la profondeur de la dimension one-hot.
- on_value : Un scalaire définissant la valeur à renseigner dans la sortie lorsque
indices[j] = i. - off_value : Un scalaire définissant la valeur à renseigner dans la sortie lorsque
indices[j] != i.
Attributs optionnels (voir Attrs ) :
- axe : L'axe à remplir (par défaut : -1, un nouvel axe le plus interne).
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 | Définiteurs d'attributs optionnels pour OneHot . |
attributs publics
opération
Operation operation
sortir
::tensorflow::Output output
fonctions publiques
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 )
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 )