เทนเซอร์โฟลว์:: ปฏิบัติการ:: แก้ไขระยะทาง

#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)

คุณลักษณะสาธารณะ

operation
output

งานสาธารณะ

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

ฟังก์ชันคงที่สาธารณะ

Normalize (bool x)

โครงสร้าง

เทนเซอร์โฟลว์ :: ops :: แก้ไขระยะทาง :: Attrs

ตัวตั้งค่าแอ็ตทริบิวต์ทางเลือกสำหรับ EditDistance

คุณลักษณะสาธารณะ

การดำเนินการ

Operation operation

เอาท์พุท

::tensorflow::Output output

งานสาธารณะ

แก้ไขระยะทาง

 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 

ตัวดำเนินการ::tensorflow::อินพุต

 operator::tensorflow::Input() const 

ตัวดำเนินการ::tensorflow::เอาต์พุต

 operator::tensorflow::Output() const 

ฟังก์ชันคงที่สาธารณะ

ทำให้เป็นมาตรฐาน

Attrs Normalize(
  bool x
)