【发布时间】:2020-08-19 05:07:59
【问题描述】:
object_for_each_prior = tf.constant([1 for i in range(8732)])
-><tf.Tensor: shape=(8732,), dtype=int32, numpy=array([1, 1, 1, ..., 1, 1, 1], dtype=int32)>
那如果我想得到1148,1149的位置
prior_for_each_object = tf.constant([1148,1149])
object_for_each_prior[prior_for_each_object]
然后我收到以下错误
TypeError: Only integers, slices (`:`), ellipsis (`...`), tf.newaxis (`None`) and scalar tf.int32/tf.int64 tensors are valid indices, got <tf.Tensor: shape=(2,), dtype=int32, numpy=array([1148, 1149], dtype=int32)>
如果我想通过索引获取张量的数字,我应该如何处理它?
【问题讨论】:
标签: numpy tensorflow tensorflow2.0