我已经考虑过这两个帖子(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: DataType float32 for attr 'T' not in list of allowed values: int32, int64
显然一切正常,但问题是这个错误是什么?它是从哪里来的?在
我发现问题了。问题来自
numOfState
。我发现它的类型是float32
。因此,通过将此变量转换为int来解决该问题:相关问题 更多 >
编程相关推荐