我试图连接两个张量,它们都是float64类型的。
tf.concat(predictions[:,:5], max_ind)
但是我得到了一个错误
ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float64: <tf.Tensor: id=44, shape=(4800,), dtype=float64, numpy=array([0., 0., 0., ..., 0., 0., 0.])>
我不明白,因为张量都是float64。
发布于 2020-03-21 22:44:29
tf.concat希望将values与应用操作的axis连接起来。据我从错误中了解到,模型认为您提供的max_ind是axis,这就是为什么它给出了一个错误,说明轴不应该是浮点数,而应该是整数。如果您试图连接predictions[:,:5]和max_ind,您应该按以下方式使用它:
tf.concat([predictions[:,:5], max_ind], -1) 我用-1作为轴,但你可以根据需要调整它。
https://stackoverflow.com/questions/60793842
复制相似问题