Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
aliran tensor:: operasi:: Sunting Jarak
#include <array_ops.h>
Menghitung Jarak Edit Levenshtein (mungkin dinormalisasi).
Ringkasan
Inputnya adalah urutan panjang variabel yang disediakan oleh SparseTensors (hypothesis_indices, hypothesis_values, hypotesis_shape) dan (truth_indices, truth_values, truth_shape).
Masukannya adalah:
Argumen:
- ruang lingkup: Objek Lingkup
- hipotesis_indeks: Indeks daftar hipotesis SparseTensor. Ini adalah matriks N x R int64.
- nilai_hipotesis: Nilai daftar hipotesis SparseTensor. Ini adalah vektor dengan panjang N.
- hypotesis_shape : Bentuk daftar hipotesis SparseTensor. Ini adalah vektor dengan panjang R.
- truth_indices: Indeks daftar kebenaran SparseTensor. Ini adalah matriks M x R int64.
- truth_values: Nilai daftar kebenaran SparseTensor. Ini adalah vektor dengan panjang M.
- truth_shape : indeks kebenaran, vektor.
Atribut opsional (lihat Attrs
):
- normalisasi: boolean (jika benar, jarak edit dinormalisasi berdasarkan panjang kebenaran).
Outputnya adalah:
Pengembalian:
-
Output
: Tensor float padat dengan rank R - 1.
Sebagai contoh masukan:
// 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
Outputnya adalah:
// 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
Konstruktor dan Destruktor |
---|
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) |
Atribut publik
Fungsi publik
simpul
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Keluaran
operator::tensorflow::Output() const
Fungsi statis publik
Normalisasi
Attrs Normalize(
bool x
)
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 2025-07-26 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\nArguments:\n\n- scope: A [Scope](/versions/r2.2/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.2/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.2/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.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r2.2/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.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_shape, const `[EditDistance::Attrs](/versions/r2.2/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.2/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_edit_distance_1aa1567444ddf9495875bb89e4815572b6) | `::`[tensorflow::Output](/versions/r2.2/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.2/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.2/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs) | Optional attribute setters for [EditDistance](/versions/r2.2/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```"]]