W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
edit_distance (
hypothesis ,
truth ,
normalize = True ,
name = 'edit_distance'
)
定義在:tensorflow/python/ops/array_ops.py.
參見(jiàn)指南:數(shù)學(xué)函數(shù)>序列比較和索引
計(jì)算序列之間的編輯距離.
該操作采用可變長(zhǎng)度序列(假設(shè)(hypothesis)和真值(truth)),每個(gè)序列都提供 SparseTensor,并計(jì)算編輯距離.通過(guò)將規(guī)范化設(shè)置為 true, 可以將編輯距離正常化.
例如,給出以下輸入:
# 'hypothesis' is a tensor of shape `[2, 1]` with variable-length values:
# (0,0) = ["a"]
# (1,0) = ["b"]
hypothesis = tf.SparseTensor(
[[0, 0, 0],
[1, 0, 0]],
["a", "b"]
(2, 1, 1))
# 'truth' is a tensor of shape `[2, 2]` with variable-length values:
# (0,0) = []
# (0,1) = ["a"]
# (1,0) = ["b", "c"]
# (1,1) = ["a"]
truth = tf.SparseTensor(
[[0, 1, 0],
[1, 0, 0],
[1, 0, 1],
[1, 1, 0]]
["a", "b", "c", "a"],
(2, 2, 2))
normalize = True
此操作將返回以下內(nèi)容:
# 'output' is a tensor of shape `[2, 2]` 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
返回秩為 R - 1 的稠密 Tensor,其中 R 是 SparseTensor 輸入 hypothesis(假設(shè)) 和 truth(真值) 的秩.
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: