Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/cmake/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 两个不同长度张量的交集_Tensorflow - Fatal编程技术网

Tensorflow 两个不同长度张量的交集

Tensorflow 两个不同长度张量的交集,tensorflow,Tensorflow,我有张流的情况。我想找到两个不同形状的二维张量的交点 例如: object_ids_ [[0 0] [0 1] [1 1]] object_ids_more_07_ [[0 0] [0 1] [0 2] [1 0] [1 2]] 我想要的输出是: [[0,0]

我有张流的情况。我想找到两个不同形状的二维张量的交点

例如:

object_ids_  [[0 0]
              [0 1]
              [1 1]]

object_ids_more_07_  [[0 0]
                      [0 1]
                      [0 2]
                      [1 0]
                      [1 2]]
我想要的输出是:

[[0,0], 
 [0,1]]
我遇到了“tf.sets.set\U交叉点”,tensorflow页面:

但无法对不同形状的张量执行此操作。我发现的另一个实现位于:

但是很难复制2D张量


任何帮助都将不胜感激,谢谢一种方法是对所有组合进行
减法->绝对值->求和
,然后得到与零匹配的索引。可以使用
广播
实现

a = tf.constant([[0,0],[0,1],[1,1]])
b = tf.constant([[0, 0],[0, 1],[0,2],[1, 0],[1, 2]])

find_match = tf.reduce_sum(tf.abs(tf.expand_dims(b,0) - tf.expand_dims(a,1)),2)

indices = tf.transpose(tf.where(tf.equal(find_match, tf.zeros_like(find_match))))[0]

out = tf.gather(a, indices)

with tf.Session() as sess:
   print(sess.run(out))
#Output
#[[0 0]
#[0 1]]