本文整理汇总了Python中tf_nndistance.nn_distance方法的典型用法代码示例。如果您正苦于以下问题:Python tf_nndistance.nn_distance方法的具体用法?Python tf_nndistance.nn_distance怎么用?Python tf_nndistance.nn_distance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tf_nndistance
的用法示例。
在下文中一共展示了tf_nndistance.nn_distance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import tf_nndistance [as 别名]
# 或者: from tf_nndistance import nn_distance [as 别名]
def __init__(self, seq_length, num_points=128):
self.ground_truth = tf.placeholder(tf.float32, [1, seq_length, num_points, 3])
self.prediction = tf.placeholder(tf.float32, [1, seq_length, num_points, 3])
gt_frames = tf.split(value=self.ground_truth, num_or_size_splits=seq_length, axis=1)
gt_frames = [tf.squeeze(input=frame, axis=[1]) for frame in gt_frames]
pd_frames = tf.split(value=self.prediction, num_or_size_splits=seq_length, axis=1)
pd_frames = [tf.squeeze(input=frame, axis=[1]) for frame in pd_frames]
cds, emds = [], []
for i in range(seq_length):
match = tf_approxmatch.approx_match(gt_frames[i], pd_frames[i])
emd_distance = tf.reduce_mean(tf_approxmatch.match_cost(gt_frames[i], pd_frames[i], match))
emds.append(emd_distance)
dists_forward, _, dists_backward, _ = tf_nndistance.nn_distance(pd_frames[i], gt_frames[i])
cd_distance = tf.reduce_mean(dists_forward+dists_backward)
cds.append(cd_distance)
self.cds = tf.stack(cds, 0)
self.emds = tf.stack(emds, 0)