tensorflow::ops::EditDistance

#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

Các đầu vào là các chuỗi có độ dài thay đổi được cung cấp bởi SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) và (truth_indices, truth_values, truth_shape).

Các thông số đầu vào là:

Luận điểm:

  • phạm vi: Một đối tượng Phạm vi
  • hypothesis_indices: Các chỉ số của danh sách giả thuyết SparseTensor. Đây là ma trận N x R int64.
  • hypothesis_values: Các giá trị của danh sách giả thuyết SparseTensor. Đây là một vectơ có độ dài N.
  • hypothesis_shape: Hình dạng của SparseTensor danh sách giả thuyết. Đây là một vectơ có độ dài R.
  • truth_indices: Các chỉ số của danh sách chân lý SparseTensor. Đây là ma trận int64 M x R.
  • truth_values: Các giá trị của danh sách chân lý SparseTensor. Đây là một vectơ có độ dài M.
  • truth_shape: chỉ số chân lý, vectơ.

Các thuộc tính tùy chọn (xem Attrs ):

  • normalize: boolean (nếu true, khoảng cách chỉnh sửa sẽ được chuẩn hóa theo độ dài của giá trị thực).

Kết quả đầu ra là:

Trả về:

  • Output : Một tensor float dày đặc với hạng R - 1.

Ví dụ về dữ liệu đầu vào:

// 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

Kết quả đầ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 khởi 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

operation
output

Chức năng công cộng

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

Các hàm tĩnh công khai

Normalize (bool x)

Cấu trúc

tensorflow::ops::EditDistance::Attrs

Các thiết lập thuộc tính tùy chọn cho EditDistance .

Thuộc tính công khai

hoạt động

Operation operation

đầu ra

::tensorflow::Output output

Chức năng công cộng

Chỉnh sửa khoảng cách

 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
)

Chỉnh sửa khoảng cách

 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
)

nút

::tensorflow::Node * node() const 

operator::tensorflow::Input

 operator::tensorflow::Input() const 

operator::tensorflow::Output

 operator::tensorflow::Output() const 

Các hàm tĩnh công khai

Chuẩn hóa

Attrs Normalize(
  bool x
)