tensoreflusso:: ops:: OneHot

#include <array_ops.h>

Restituisce un tensore one-hot.

Riepilogo

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

Se gli indices di input sono di rango N , l'output avrà rango N+1 . Il nuovo asse viene creato axis dimensione (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 è un vettore di length features , la forma di 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 di 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)
  ]

Argomenti:

  • scope: un oggetto Scope
  • indici: un tensore di indici.
  • profondità: uno scalare che definisce la profondità di una dimensione calda.
  • on_value: uno scalare che definisce il valore da compilare nell'output quando indices[j] = i .
  • off_value: uno scalare che definisce il valore da compilare nell'output quando indices[j] != i .

Attributi facoltativi (vedi Attrs ):

  • asse: l'asse da riempire (impostazione predefinita: -1, un nuovo asse più interno).

Ritorna:

  • Output : il tensore uni-caldo.

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 pubbliche statiche

Axis (int64 x)

Strutture

tensorflow:: ops:: OneHot:: Attrs

Setter di attributi facoltativi 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::tensorflow::Output

 operator::tensorflow::Output() const 

Funzioni pubbliche statiche

Asse

Attrs Axis(
  int64 x
)