tf.edit_distance()函数

#  coding:utf-8
import tensorflow as tf
import numpy as np
images1 = [[1,2,3],[2,3,1],[2,3,1],[2,3,1]]
images2 = [[1,2,3],[2,3,2],[2,1,2],[5,53,51]]
def sparse_tuple_from(sequences, dtype=np.int32):
    indices = []
    values = []
    for n, seq in enumerate(sequences):
        indices.extend(zip([n] * len(seq), range(len(seq))))
        values.extend(seq)
    indices = np.asarray(indices, dtype=np.int64)
    values = np.asarray(values, dtype=dtype)
    shape = np.asarray([len(sequences), indices.max(0)[1] + 1], dtype=np.int64)
    return tf.SparseTensor(indices=indices, values=values, dense_shape=shape)
distence = tf.edit_distance(sparse_tuple_from(images1),sparse_tuple_from(images2))
with tf.Session() as sess:
    distence_ = sess.run([distence])
    print(distence_)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值