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à:

Tranh 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

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

Trình 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 

toán tử::tenorflow::Đầu vào

 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
)