def build_continuous_jaccard_distance_network(fps1, fps2):
"""
Given two batches of fingerprints, compute the distance between
the i'th fingerprint from each batch, using the continuous
generalization of the Jaccard distance:
1 - \Sum(min(x_i, y_i)) / \Sum(max(x_i, y_i))
see (Duvenaud, NIPS 2015)
"""
intersect = tf.reduce_sum(tf.minimum(fps1, fps2), [1], name="intersect")
union = tf.reduce_sum(tf.maximum(fps1, fps2), [1], name="union")
tanimoto = tf.div(intersect, union, name="tanimoto")
jaccard = tf.sub(1.0, tanimoto, name="jaccard")
return jaccard
评论列表
文章目录