tensorflow::ops::OneHot

#include <array_ops.h>

Mengembalikan tensor one-hot.

Ringkasan

Lokasi yang diwakili oleh indeks dalam indices mengambil nilai on_value , sedangkan semua lokasi lainnya mengambil nilai off_value .

Jika indices input memiliki rank N , maka output akan memiliki rank N+1 . Sumbu baru dibuat pada dimensi axis (default: sumbu baru ditambahkan di akhir).

Jika indices berupa skalar, maka bentuk outputnya akan berupa vektor dengan panjang depth .

Jika indices merupakan vektor dengan panjang features , maka bentuk outputnya akan menjadi:

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

Jika indices berupa matriks (batch) dengan bentuk [batch, features] , maka bentuk outputnya adalah:

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

Contoh

Anggaplah bahwa

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

Maka outputnya adalah [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)

Anggaplah bahwa

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

Maka outputnya adalah [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)

Anggaplah bahwa

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

Maka outputnya adalah [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)
  ]

Argumen:

  • Cakupan: Objek Cakupan
  • indeks: Sebuah tensor indeks.
  • kedalaman: Sebuah besaran skalar yang mendefinisikan kedalaman dimensi one-hot.
  • on_value: Sebuah skalar yang mendefinisikan nilai yang akan diisi dalam output ketika indices[j] = i .
  • off_value: Sebuah skalar yang mendefinisikan nilai yang akan diisi dalam output ketika indices[j] != i .

Atribut opsional (lihat Attrs ):

  • axis: Sumbu yang akan diisi (default: -1, sumbu terdalam yang baru).

Mengembalikan:

Konstruktor dan Destruktor

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)

Atribut publik

operation
output

Fungsi publik

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

Fungsi statis publik

Axis (int64 x)

Struktur

tensorflow::ops::OneHot::Attrs

Pengaturan atribut opsional untuk OneHot .

Atribut publik

operasi

Operation operation

keluaran

::tensorflow::Output output

Fungsi publik

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
)

simpul

::tensorflow::Node * node() const 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const 

Fungsi statis publik

Sumbu

Attrs Axis(
  int64 x
)