[英]TypeError:DataType float32 for attr 'Tindices' not in list of allowed values: int32, int64
[英]DataType float32 for attr 'T' not in list of allowed values: int32, int64
我已经考虑了这两篇文章( this和this ),但它们不是我的问题和解决方案。 我有以下代码在tf中创建前馈网络:
step = 500
fromState = 0
toState = 5000000
numOfState = (toState - fromState) / step
numOfAction = 11
tf.reset_default_graph()
inputs1 = tf.placeholder(shape=[1,numOfState], dtype = tf.float32)
W = tf.Variable(tf.random_uniform([numOfState,4],0,0.01),)
Qout = tf.matmul(inputs1,W)
predict = tf.argmax(Qout,1)
但是,我在此行Qout = tf.matmul(inputs1,W)
遇到以下错误:
TypeError:attr'T'的数据类型float32不在允许值列表中:int32,int64
显然一切正常,但问题是此错误是什么,它是从哪里来的?
我发现了问题。 问题来自numOfState
。 我发现它的类型是float32
。 因此,可以通过将该变量转换为int来解决问题:
#numOfState = (toState - fromState) / step
# change to
numOfState = int((toState - fromState) / step)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.