Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
dòng chảy căng:: ôi:: Chỉnh sửa Khoảng cách
#include <array_ops.h>
Tính toán Khoảng cách chỉnh sửa Levenshtein (có thể được chuẩn hóa).
Bản tóm tắt
Đầu vào là các chuỗi có độ dài thay đổi được cung cấp bởi SparseTensors (giả thuyết_indices, giả thuyết_giá trị, giả thuyết_hình dạng) và (truth_indices, true_values, Truth_shape).
Các đầu vào là:
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- giả thuyết_indices: Các chỉ số của danh sách giả thuyết SparseTensor. Đây là ma trận N x R int64.
- giả thuyết_values: Các giá trị của danh sách giả thuyết SparseTensor. Đây là một vectơ có độ dài N.
- giả thuyết_shape: Hình dạng của danh sách giả thuyết SparseTensor. Đây là một vectơ có độ dài R.
- Truth_indices: Các chỉ số của danh sách sự thật SparseTensor. Đây là ma trận int64 M x R.
- Truth_values: Các giá trị của danh sách sự thật SparseTensor. Đây là một vectơ có độ dài M.
- true_shape: chỉ số chân lý, vector.
Thuộc tính tùy chọn (xem Attrs
):
- normalize: boolean (nếu đúng, khoảng cách chỉnh sửa được chuẩn hóa theo độ dài của sự thật).
Đầu ra là:
Trả về:
-
Output
: Một tenxơ float dày đặc có hạng R - 1.
Đối với đầu vào ví dụ:
// 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
Đầu ra sẽ là:
// 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
Hàm tạo và hàm hủy |
---|
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) |
Thuộc tính công khai
Chức năng công cộng
nút
::tensorflow::Node * node() const
operator::tensorflow::Input() const
toán tử::tenorflow::Đầu ra
operator::tensorflow::Output() const
Các hàm tĩnh công khai
Bình thường hóa
Attrs Normalize(
bool x
)
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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```"]]