тензорный поток:: опс:: OneHot
#include <array_ops.h>Возвращает горячий тензор.
Краткое содержание
Местоположение, представленное индексами в indices принимает значение on_value , тогда как все остальные местоположения принимают значение off_value .
Если входные indices имеют ранг N , выходные данные будут иметь ранг N+1 . Новая ось создается на axis измерения (по умолчанию: новая ось добавляется в конце).
Если indices является скаляром, выходная форма будет вектором depth длины.
Если indices представляет собой вектор длины features , выходная форма будет такой:
features x depth if axis == -1 depth x features if axis == 0
Если indices представляет собой матрицу (пакет) с формой [batch, features] , выходная форма будет такой:
batch x features x depth if axis == -1 batch x depth x features if axis == 1 depth x batch x features if axis == 0
Примеры
Предположим, что
indices = [0, 2, -1, 1] depth = 3 on_value = 5.0 off_value = 0.0 axis = -1
Тогда выход будет [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)
Предположим, что
indices = [0, 2, -1, 1] depth = 3 on_value = 0.0 off_value = 3.0 axis = 0
Тогда выход будет [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)
Предположим, что
indices = [[0, 2], [1, -1]] depth = 3 on_value = 1.0 off_value = 0.0 axis = -1
Тогда выход будет [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)
]Аргументы:
- область: объект области.
- индексы: Тензор индексов.
- глубина: скаляр, определяющий глубину одного горячего измерения.
- on_value: скаляр, определяющий значение для заполнения вывода, когда
indices[j] = i. - off_value: скаляр, определяющий значение для заполнения вывода, когда
indices[j] != i.
Необязательные атрибуты (см. Attrs ):
- ось: ось для заполнения (по умолчанию: -1, новая самая внутренняя ось).
Возврат:
-
Output: Горячий тензор.
Конструкторы и деструкторы | |
|---|---|
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) |
Публичные атрибуты | |
|---|---|
operation | |
output | |
Общественные функции | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Публичные статические функции | |
|---|---|
Axis (int64 x) | |
Структуры | |
|---|---|
| tensorflow::ops::OneHot::Attrs | Дополнительные установщики атрибутов для OneHot . |
Публичные атрибуты
операция
Operation operation
выход
::tensorflow::Output output
Общественные функции
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 )
узел
::tensorflow::Node * node() const
оператор::tensorflow::Input
operator::tensorflow::Input() const
оператор::tensorflow::Выход
operator::tensorflow::Output() const
Публичные статические функции
Ось
Attrs Axis( int64 x )