Deeprl-agents: DRQN: Error prefix tensor must be either a scalar or vector

Created on 13 Jul 2017  路  3Comments  路  Source: awjuliani/DeepRL-Agents

I tried the DRQN for partial observations, but I got the error:

ValueError: prefix tensor must be either a scalar or vector, but saw tensor: Tensor("Placeholder_2:0", dtype=int32)

----Error happens in this line-------

self.state_in = rnn_cell.zero_state(self.batch_size, tf.float32)

Most helpful comment

I found that there are 3 consecutive lines:

self.batch_size = tf.placeholder(dtype=tf.int32)
self.convFlat = tf.reshape(slim.flatten(self.conv4),[self.batch_size,self.trainLength,h_size])
self.state_in = rnn_cell.zero_state(self.batch_size, tf.float32)

I change the line:

self.batch_size = tf.placeholder(dtype=tf.int32)

into:

self.batch_size = tf.placeholder(dtype=tf.int32,shape=[])

And it works.

All 3 comments

I found that there are 3 consecutive lines:

self.batch_size = tf.placeholder(dtype=tf.int32)
self.convFlat = tf.reshape(slim.flatten(self.conv4),[self.batch_size,self.trainLength,h_size])
self.state_in = rnn_cell.zero_state(self.batch_size, tf.float32)

I change the line:

self.batch_size = tf.placeholder(dtype=tf.int32)

into:

self.batch_size = tf.placeholder(dtype=tf.int32,shape=[])

And it works.

Thank you!!!! I thought for sure the code was doomed, per https://github.com/tensorflow/tensorflow/issues/10213

But this fix is correct and worked for me, too!

Really hope @awjuliani can fix in the code (modify literally one line), thank you sir!

Just made the change! Thanks for pointing this out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IbrahimSobh picture IbrahimSobh  路  30Comments

IbrahimSobh picture IbrahimSobh  路  10Comments

jjisnow picture jjisnow  路  3Comments

AliBaheri picture AliBaheri  路  3Comments

LeenaShekhar picture LeenaShekhar  路  3Comments