Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/331.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.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
Python Tensorflow,通过空间索引从图像中收集_Python_Tensorflow - Fatal编程技术网

Python Tensorflow,通过空间索引从图像中收集

Python Tensorflow,通过空间索引从图像中收集,python,tensorflow,Python,Tensorflow,我有一批图像,[B,H,W,3],还有空间N索引,[B,N,2]。2代表H和W。 有人知道如何从图像中获取N个像素吗?因此得到的形状是[B,N,3] 似乎tf.collection\u nd有帮助,但我还是不知道该怎么做。多谢各位 使用批次dims参数: params = tf.random.uniform((5, 100, 200, 3)) inds = tf.random.uniform((5, 300, 2), 0, 100, tf.int32) output = tf.gather_nd

我有一批图像,
[B,H,W,3]
,还有空间N索引,
[B,N,2]
。2代表H和W。
有人知道如何从图像中获取N个像素吗?因此得到的形状是
[B,N,3]

似乎
tf.collection\u nd
有帮助,但我还是不知道该怎么做。多谢各位


使用
批次dims
参数:

params = tf.random.uniform((5, 100, 200, 3))
inds = tf.random.uniform((5, 300, 2), 0, 100, tf.int32)
output = tf.gather_nd(params, inds, batch_dims=1)

使用
batch_dims
参数:

params = tf.random.uniform((5, 100, 200, 3))
inds = tf.random.uniform((5, 300, 2), 0, 100, tf.int32)
output = tf.gather_nd(params, inds, batch_dims=1)

非常感谢。我确认它的工作原理和我预期的一样完美。你救了我的命。现在,我更好地了解了如何使用TF1.12处理库依赖项的批处理工作。我发现TF1.12的
tf.gather\u nd
没有
batch\u dims
。你知道解决问题的其他方法吗?不,不幸的是,我没有和TF1一起工作。我确认它的工作原理和我预期的一样完美。你救了我的命。现在,我更好地了解了如何使用TF1.12处理库依赖项的批处理工作。我发现TF1.12的
tf.gather\u nd
没有
batch\u dims
。你知道解决问题的其他方法吗?不,很遗憾,我没有使用TF1