tensorflow:: ops:: OneHot

#include <array_ops.h>

Restituisce un tensore one-hot.

Riepilogo

Le posizioni rappresentate dagli indici in indices assumono il valore on_value , mentre tutte le altre posizioni assumono il valore off_value .

Se gli indices di input hanno rango N , l'output avrà rango N+1 . Il nuovo asse viene creato axis delle dimensioni (impostazione predefinita: il nuovo asse viene aggiunto alla fine).

Se indices è uno scalare, la forma di output sarà un vettore di lunghezza depth .

Se indices sono un vettore di lunghezza features , la forma dell'output sarà:

  features x depth if axis == -1
  depth x features if axis == 0

Se indices è una matrice (batch) con forma [batch, features] , la forma dell'output sarà:

  batch x features x depth if axis == -1
  batch x depth x features if axis == 1
  depth x batch x features if axis == 0

Esempi

Supponiamo che

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 5.0
  off_value = 0.0
  axis = -1

Quindi l'output è [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)

Supponiamo che

  indices = [0, 2, -1, 1]
  depth = 3
  on_value = 0.0
  off_value = 3.0
  axis = 0

Quindi l'output è [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)

Supponiamo che

  indices = [[0, 2], [1, -1]]
  depth = 3
  on_value = 1.0
  off_value = 0.0
  axis = -1

Quindi l'output è [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)
  ]

Argomentazioni:

  • ambito: un oggetto Scope
  • indici: Un tensore di indici.
  • profondità: uno scalare che definisce la profondità della dimensione one-hot.
  • on_value: Uno scalare che definisce il valore da inserire nell'output quando indices[j] = i .
  • off_value: uno scalare che definisce il valore da inserire nell'output quando indices[j] != i .

Attributi opzionali (vedere Attrs ):

  • asse: L'asse da riempire (predefinito: -1, un nuovo asse più interno).

Resi:

  • Output : Il tensore one-hot.

Costruttori e distruttori

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)

attributi pubblici

operation
output

Funzioni pubbliche

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

Funzioni statiche pubbliche

Axis (int64 x)

Strutture

tensorflow:: ops:: OneHot:: Attrs

Impostazioni opzionali degli attributi per OneHot .

attributi pubblici

operazione

Operation operation

produzione

::tensorflow::Output output

Funzioni pubbliche

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
)

nodo

::tensorflow::Node * node() const 

operatore::tensorflow::Input

 operator::tensorflow::Input() const 

operatore::tensoreflusso::output

 operator::tensorflow::Output() const 

Funzioni statiche pubbliche

Asse

Attrs Axis(
  int64 x
)