TypeError: list of tensors when waiting for a single tensor - when using const with tf.random_normal

I have the following TensorFlow code:

tf.constant(tf.random_normal([time_step, batch_size], -1, 1))

      

I receive TypeError: List of Tensors when single Tensor expected

. Could you please tell me what is wrong with the code?

+3


source to share


2 answers


Someone else answered this question in another thread at fooobar.com/questions/1002229 / ...

Essentially tf.constant()

takes a NumPy array as an argument or some sort of array or just a value.

tf.random_normal()

returns a tensor, which cannot be an argument tf.constant()

.



To fix this use tf.Variable()

instead tf.constant()

.

See the answer at the link. Man explains it better.

+5


source


tf.constant

suppose it has a constant argument - value

. This value

can be a constant value or a list of values โ€‹โ€‹of the type dtype

. You cannot create a constant tensor that has its next tensor.



0


source







All Articles