Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataType float32 for attr 'T' not in list of allowed values: int32, int64

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?

like image 393
OmG Avatar asked Oct 29 '17 19:10

OmG


1 Answers

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)
like image 147
OmG Avatar answered Sep 28 '22 17:09

OmG