I have the following TensorFlow code:
tf.constant(tf.random_normal([time_step, batch_size], -1, 1))
I am getting TypeError: List of Tensors when single Tensor expected
. Could you tell me what is wrong with the code?
Someone else has answered this question on another thread.
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 to tf.constant()
.
To fix this, use tf.Variable()
instead of tf.constant()
.
See the answer from the link. The person explains it better.
tf.constant
is supposed to have a constant argument - value
. Here value
can be a constant value or a list of values of type dtype
. You can't create a constant tensor that has another tensor as its value.
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