_,train_loss,acc=self.sess.run([train_op,total_losses,acc],feed_dict=feed_dict)
TypeError: Fetch argument 0.546875 has invalid type <class 'numpy.float32'>, must be a string or Tensor. (Can not convert a float32 into a Tensor or Operation.)
为什么呢,因为一个等式中的acc重名了;第一次运行后等式右边的acc变成了一个整数; 如下所示:
_,train_loss,acc=self.sess.run([train_op,total_losses,acc],feed_dict=feed_dict)
所以才会出现上述错误
解决TensorFlow中TypeError: Fetch argument has invalid type问题
本文详细解析了在使用TensorFlow进行训练时遇到的TypeError: Fetch argument has invalid type错误的原因及解决方案。错误源于变量名重复导致的数据类型冲突,通过避免变量名重复或正确转换数据类型可以有效解决此问题。
7823

被折叠的 条评论
为什么被折叠?



