จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: แก้ไขระยะทาง
#include <array_ops.h>
คำนวณระยะทางแก้ไขของ Levenshtein (อาจเป็นมาตรฐาน)
สรุป
อินพุตเป็นลำดับความยาวผันแปรได้จัดทำโดย SparseTensors (hypothesis_indices, Hypothesis_values, hypothesis_shape) และ (truth_indices, Truth_values, Truth_shape)
อินพุตคือ:
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- hypothesis_indices: ดัชนีของรายการสมมติฐาน SparseTensor นี่คือเมทริกซ์ int64 N x R
- hypothesis_values: ค่าของรายการสมมติฐาน SparseTensor นี่คือเวกเตอร์ความยาว N
- hypothesis_shape: รูปร่างของรายการสมมติฐาน SparseTensor นี่คือเวกเตอร์ความยาว R
- Truth_indices: ดัชนีของรายการความจริง SparseTensor นี่คือเมทริกซ์ M x R int64
- Truth_values: ค่าของรายการความจริง SparseTensor นี่คือเวกเตอร์ความยาว M
- Truth_shape: ดัชนีความจริง เวกเตอร์
แอ็ตทริบิวต์ทางเลือก (ดู Attrs
):
- ทำให้เป็นมาตรฐาน: บูลีน (หากเป็นจริง ระยะทางที่แก้ไขจะถูกทำให้เป็นมาตรฐานตามความยาวของความจริง)
ผลลัพธ์คือ:
ผลตอบแทน:
-
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) |
คุณลักษณะสาธารณะ
งานสาธารณะ
โหนด
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
ฟังก์ชันคงที่สาธารณะ
ทำให้เป็นมาตรฐาน
Attrs Normalize(
bool x
)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 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/r1.15/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/r1.15/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/r1.15/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/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_values, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` hypothesis_shape, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_indices, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_values, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` truth_shape, const `[EditDistance::Attrs](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_edit_distance_1aa1567444ddf9495875bb89e4815572b6) | `::`[tensorflow::Output](/versions/r1.15/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/r1.15/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/r1.15/api_docs/cc/struct/tensorflow/ops/edit-distance/attrs) | Optional attribute setters for [EditDistance](/versions/r1.15/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```"]]