tensorflow::ops::EditDistance
#include <array_ops.h>
Вычисляет (возможно, нормализованное) расстояние Левенштейна.
Краткое описание
На входе — последовательности переменной длины, предоставляемые SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) и (truth_indices, truth_values, truth_shape).
На входе:
Args:
- scope: Объект Scope
- hypothesis_indices: Индексы SparseTensor списка гипотез. Это матрица N x R типа int64.
- hypothesis_values: Значения SparseTensor списка гипотез. Это вектор длины N.
- hypothesis_shape: Форма SparseTensor списка гипотез. Это вектор длины R.
- truth_indices: Индексы SparseTensor списка истинных значений. Это матрица M x R типа int64.
- truth_values: Значения SparseTensor списка истинных значений. Это вектор длины M.
- truth_shape: Индексы truth, вектор.
Необязательные атрибуты (см. Attrs):
- normalize: boolean (если true, расстояния редактирования нормализуются длиной truth).
На выходе:
Returns:
-
Output: Плотное тензорное значение с плавающей запятой с рангом 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 )
© 2022 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/api_docs/cc/class/tensorflow/ops/edit-distance