Help protect the Great Barrier Reef with TensorFlow on Kaggle

EditDistance

public final class EditDistance

Computes the (possibly normalized) Levenshtein Edit Distance.

The inputs are variable-length sequences provided by SparseTensors (hypothesis_indices, hypothesis_values, hypothesis_shape) and (truth_indices, truth_values, truth_shape).

The inputs are:

Nested Classes

 class EditDistance.Options Optional attributes for `EditDistance`

Public Methods

 Output asOutput() Returns the symbolic handle of a tensor. static EditDistance create(Scope scope, Operand hypothesisIndices, Operand hypothesisValues, Operand hypothesisShape, Operand truthIndices, Operand truthValues, Operand truthShape, Options... options) Factory method to create a class wrapping a new EditDistance operation. static EditDistance.Options normalize(Boolean normalize) Output output() A dense float tensor with rank R - 1.

Public Methods

public Output<Float> asOutput()

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static EditDistance create(Scope scope, Operand<Long> hypothesisIndices, Operand<T> hypothesisValues, Operand<Long> hypothesisShape, Operand<Long> truthIndices, Operand<T> truthValues, Operand<Long> truthShape, Options... options)

Factory method to create a class wrapping a new EditDistance operation.

Parameters
scope current scope The indices of the hypothesis list SparseTensor. This is an N x R int64 matrix. The values of the hypothesis list SparseTensor. This is an N-length vector. The shape of the hypothesis list SparseTensor. This is an R-length vector. The indices of the truth list SparseTensor. This is an M x R int64 matrix. The values of the truth list SparseTensor. This is an M-length vector. truth indices, vector. carries optional attributes values
Returns
• a new instance of EditDistance

public static EditDistance.Options normalize(Boolean normalize)

Parameters
normalize boolean (if true, edit distances are normalized by length of truth). The output is:

public Output<Float> output()

A dense float tensor with rank R - 1.

For the example input:

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

The output will be:

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

[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]