tensorflow::ops::EditDistance
#include <array_ops.h>
Вычисляет (возможно, нормализованное) расстояние Левенштейна.
Краткое описание
На вход подаются последовательности переменной длины, предоставленные SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) и (truth_indices, truth_values, truth_shape).
На вход подаются:
Аргументы:
- scope: Объект Scope
- hypothesis_indices: Индексы списка гипотез SparseTensor. Это матрица int64 размером N x R.
- hypothesis_values: Значения списка гипотез SparseTensor. Это вектор длины N.
- hypothesis_shape: Форма списка гипотез SparseTensor. Это вектор длины R.
- truth_indices: Индексы списка истинных значений SparseTensor. Это матрица int64 размером M x R.
- truth_values: Значения списка истинных значений SparseTensor. Это вектор длины M.
- truth_shape: Индексы истинных значений, вектор.
Необязательные атрибуты (см. Attrs):
- normalize: boolean (если true, расстояния редактирования нормализуются длиной truth).
На выходе:
Возвращает:
-
Output: Плотное тензорное значение с типом float и рангом R - 1.
Для входных данных примера:
// hypothesis represents a 2x1 matrix with variable-length values:
// (0,0) = ["a"]
// (1,0) = ["b"]
hypothesis_indices = [[0, 0, 0],
[1, 0, 0]]
hypothesis_values = ["a", "b"]
hypothesis_shape = [2, 1, 1]
// truth represents a 2x2 matrix with variable-length values:
// (0,0) = []
// (0,1) = ["a"]
// (1,0) = ["b", "c"]
// (1,1) = ["a"]
truth_indices = [[0, 1, 0],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0]]
truth_values = ["a", "b", "c", "a"]
truth_shape = [2, 2, 2]
normalize = true
На выходе будет:
// output is a 2x2 matrix with edit distances normalized by truth lengths.
output = [[inf, 1.0], // (0,0): no truth, (0,1): no hypothesis
[0.5, 1.0]] // (1,0): addition, (1,1): no hypothesis | Конструкторы и деструкторы | |
|---|---|
EditDistance(const ::tensorflow::Scope & scope, ::tensorflow::Input hypothesis_indices, ::tensorflow::Input hypothesis_values, ::tensorflow::Input hypothesis_shape, ::tensorflow::Input truth_indices, ::tensorflow::Input truth_values, ::tensorflow::Input truth_shape) | |
EditDistance(const ::tensorflow::Scope & scope, ::tensorflow::Input hypothesis_indices, ::tensorflow::Input hypothesis_values, ::tensorflow::Input hypothesis_shape, ::tensorflow::Input truth_indices, ::tensorflow::Input truth_values, ::tensorflow::Input truth_shape, const EditDistance::Attrs & attrs) |
| Общедоступные атрибуты | |
|---|---|
operation | |
output | |
| Общедоступные функции | |
|---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const | |
| Общедоступные статические функции | |
|---|---|
Normalize(bool x) | |
| Структуры | |
|---|---|
| tensorflow::ops::EditDistance::Attrs | Необязательные устанавливатели атрибутов для EditDistance. |
Общедоступные атрибуты
operation
Operation operation
output
::tensorflow::Output output
Общедоступные функции
EditDistance
EditDistance( const ::tensorflow::Scope & scope, ::tensorflow::Input hypothesis_indices, ::tensorflow::Input hypothesis_values, ::tensorflow::Input hypothesis_shape, ::tensorflow::Input truth_indices, ::tensorflow::Input truth_values, ::tensorflow::Input truth_shape )
EditDistance
EditDistance( const ::tensorflow::Scope & scope, ::tensorflow::Input hypothesis_indices, ::tensorflow::Input hypothesis_values, ::tensorflow::Input hypothesis_shape, ::tensorflow::Input truth_indices, ::tensorflow::Input truth_values, ::tensorflow::Input truth_shape, const EditDistance::Attrs & attrs )
node
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Общедоступные статические функции
Normalize
Attrs Normalize( bool x )
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/cc/class/tensorflow/ops/edit-distance