When I declare my variable like this:
x = tf.Variable([len(_ELEMENT_LIST), 4], dtype=tf.float32)
I get the following error:
E0622 20:04:25.241938 21886 app.py:544] Top-level exception: Shape must be rank 1 but is rank 2 for 'input_layer/concat' (op: 'ConcatV2') with input shapes: [5], [5,1], [5,1], [].
E0622 20:04:25.252672 21886 app.py:545] Traceback (most recent call last):
When I do it like this:
x = tf.get_variable("x", [len(_ELEMENT_LIST), 4])
It works
I'm trying to compute Tensors using concat.
tf.concat([
x, features["y"],
features["z"]
], 1)
x = tf.Variable([len(_ELEMENT_LIST), 4], dtype=tf.float32)
the first parameter of tf.Variable
is the initial value of the variable, so in the upper statement x
is a Variable with value [len(_ELEMENT_LIST), 4]
, and it's rank of shape is 1.
x = tf.get_variable("x", [len(_ELEMENT_LIST), 4])
the second parameter of tf.get_variable
is the shape of Variable, so the rank of shape of Variable X is 2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.