![](/img/trans.png)
[英]TensorFlow Recommenders - ValueError: Shape must be rank 2 but is rank 3
[英]Tensorflow Shape must be rank 1 but is rank 2
當我這樣聲明我的變量時:
x = tf.Variable([len(_ELEMENT_LIST), 4], dtype=tf.float32)
我收到以下錯誤:
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):
當我這樣做時:
x = tf.get_variable("x", [len(_ELEMENT_LIST), 4])
有用
我正在嘗試使用concat計算張量。
tf.concat([
x, features["y"],
features["z"]
], 1)
x = tf.Variable([len(_ELEMENT_LIST), 4], dtype=tf.float32)
tf.Variable
的第一個參數是變量的初始值,因此在上面的語句中x
是值[len(_ELEMENT_LIST), 4]
的變量,其形狀等級為1。
x = tf.get_variable("x", [len(_ELEMENT_LIST), 4])
tf.get_variable
的第二個參數是變量的形狀,因此變量X的形狀等級為2。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.