我有这个使用Tensorflow 框架的 python 函数:
def compute_ap(gain_vector):
#this vector must fit the dimension of the gain_vector
index_vector = tf.range(1, gain_vector.get_shape()[0],dtype=tf.float32)
ap = tf.div(tf.reduce_sum(tf.div(tf.cast(gain_vector,tf.float32), index_vector), 1),tf.reduce_sum(tf.cast(gain_vector,tf.float32), 1))
return ap
当我运行程序时,我得到这个错误:
ValueError: Tensor conversion requested dtype float32 for Tensor with dtype int32: 'Tensor("inputs/strided_slice:0", shape=(), dtype=int32)'
好像gain_vector.get_shape()[0]没有得到增益向量的向量,有什么问题?