I have considered these two posts(this and this), but they are not my problem and solution. I have the following code to create a feed forward network in 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)
However, I've got the following error in this line Qout = tf.matmul(inputs1,W)
:
TypeError: DataType float32 for attr 'T' not in list of allowed values: int32, int64
Apparently everything is ok, but the question is what is this error and where does it come from?
I have found the problem. The problem comes from numOfState
. As I have found its type is float32
. Hence, the problem is solved by casting this variable to int:
#numOfState = (toState - fromState) / step
# change to
numOfState = int((toState - fromState) / step)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With