Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::EditDistance
#include <array_ops.h>
Computes the (possibly normalized) Levenshtein Edit Distance.
Summary
The inputs are variable-length sequences provided by SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) and (truth_indices, truth_values, truth_shape).
The inputs are:
Args:
- scope: A Scope object
- hypothesis_indices: The indices of the hypothesis list SparseTensor. This is an N x R int64 matrix.
- hypothesis_values: The values of the hypothesis list SparseTensor. This is an N-length vector.
- hypothesis_shape: The shape of the hypothesis list SparseTensor. This is an R-length vector.
- truth_indices: The indices of the truth list SparseTensor. This is an M x R int64 matrix.
- truth_values: The values of the truth list SparseTensor. This is an M-length vector.
- truth_shape: truth indices, vector.
Optional attributes (see Attrs
):
- normalize: boolean (if true, edit distances are normalized by length of truth).
The output is:
Returns:
Output
: A dense float tensor with rank R - 1.
For the example input:
// 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
The output will be:
// 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
Constructors and Destructors
|
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)
|
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Public static functions
Normalize
Attrs Normalize(
bool x
)
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tensorflow::ops::EditDistance Class Reference\n\ntensorflow::ops::EditDistance\n=============================\n\n`#include \u003carray_ops.h\u003e`\n\nComputes the (possibly normalized) Levenshtein Edit Distance.\n\nSummary\n-------\n\nThe inputs are variable-length sequences provided by SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) and (truth_indices, truth_values, truth_shape).\n\nThe inputs are:\n\nArgs:\n\n- scope: A [Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- hypothesis_indices: The indices of the hypothesis list SparseTensor. This is an N x R int64 matrix.\n- hypothesis_values: The values of the hypothesis list SparseTensor. This is an N-length vector.\n- hypothesis_shape: The shape of the hypothesis list SparseTensor. This is an R-length vector.\n- truth_indices: The indices of the truth list SparseTensor. This is an M x R int64 matrix.\n- truth_values: The values of the truth list SparseTensor. This is an M-length vector.\n- truth_shape: truth indices, vector.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs#structtensorflow_1_1ops_1_1_edit_distance_1_1_attrs)):\n\n- normalize: boolean (if true, edit distances are normalized by length of truth).\n\n\u003cbr /\u003e\n\nThe output is:\n\nReturns:\n\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A dense float tensor with rank R - 1.\n\n\u003cbr /\u003e\n\nFor the example input: \n\n```gdscript\n// hypothesis represents a 2x1 matrix with variable-length values:\n// (0,0) = [\"a\"]\n// (1,0) = [\"b\"]\nhypothesis_indices = [[0, 0, 0],\n [1, 0, 0]]\nhypothesis_values = [\"a\", \"b\"]\nhypothesis_shape = [2, 1, 1]\n\n// truth represents a 2x2 matrix with variable-length values:\n// (0,0) = []\n// (0,1) = [\"a\"]\n// (1,0) = [\"b\", \"c\"]\n// (1,1) = [\"a\"]\ntruth_indices = [[0, 1, 0],\n [1, 0, 0],\n [1, 0, 1],\n [1, 1, 0]]\ntruth_values = [\"a\", \"b\", \"c\", \"a\"]\ntruth_shape = [2, 2, 2]\nnormalize = true\n```\n\n\u003cbr /\u003e\n\nThe output will be: \n\n```scilab\n// output is a 2x2 matrix with edit distances normalized by truth lengths.\noutput = [[inf, 1.0], // (0,0): no truth, (0,1): no hypothesis\n [0.5, 1.0]] // (1,0): addition, (1,1): no hypothesis \n```\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [EditDistance](#classtensorflow_1_1ops_1_1_edit_distance_1a98448a482111a3a9542eb10497edfbdf)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_shape)` ||\n| [EditDistance](#classtensorflow_1_1ops_1_1_edit_distance_1a71ebfcdcb0c51272c8a1952352c23386)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_shape, const `[EditDistance::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs#structtensorflow_1_1ops_1_1_edit_distance_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_edit_distance_1ad892f698a1eede4c4a5e8a315e9d49f4) | [Operation](/versions/r2.14/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_edit_distance_1aa1567444ddf9495875bb89e4815572b6) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|-------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_edit_distance_1a37f2320123595e25c3b22b85bb73e4de)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_edit_distance_1a0b07c2848a5af99f253674fbe909f3ef)`() const ` | |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_edit_distance_1a3dde48ed219986c41f1a0a0409658ae1)`() const ` | |\n\n| ### Public static functions ||\n|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|\n| [Normalize](#classtensorflow_1_1ops_1_1_edit_distance_1ab7877a4f848a5e5f6682247e07a67cbb)`(bool x)` | [Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs#structtensorflow_1_1ops_1_1_edit_distance_1_1_attrs) |\n\n| ### Structs ||\n|---------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::EditDistance::Attrs](/versions/r2.14/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs) | Optional attribute setters for [EditDistance](/versions/r2.14/api_docs/cc/class/tensorflow/ops/edit-distance#classtensorflow_1_1ops_1_1_edit_distance). |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### EditDistance\n\n```gdscript\n EditDistance(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input hypothesis_indices,\n ::tensorflow::Input hypothesis_values,\n ::tensorflow::Input hypothesis_shape,\n ::tensorflow::Input truth_indices,\n ::tensorflow::Input truth_values,\n ::tensorflow::Input truth_shape\n)\n``` \n\n### EditDistance\n\n```gdscript\n EditDistance(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input hypothesis_indices,\n ::tensorflow::Input hypothesis_values,\n ::tensorflow::Input hypothesis_shape,\n ::tensorflow::Input truth_indices,\n ::tensorflow::Input truth_values,\n ::tensorflow::Input truth_shape,\n const EditDistance::Attrs & attrs\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n``` \n\nPublic static functions\n-----------------------\n\n### Normalize\n\n```text\nAttrs Normalize(\n bool x\n)\n```"]]