Я пытаюсь построить BNN, но сталкиваюсь с ошибкой в заголовке. Я попытался убедиться, что я не передаю кортеж. Керас 3. Таким образом, я обновился до TFP-Nightly 0.25.0, который совместим с Keras 3 и до сих пор сталкиваюсь с той же проблемой. Как вы можете видеть в отладке, «INP» - это тензор, а не кортеж и все еще должен быть единым, когда называется Shape.rank. < /P>
import tensorflow as tf
import tensorflow_probability as tfp # 0.25.0‑dev
tfpl = tfp.layers
inp = tf.keras.Input(shape=(10,))
print("[DEBUG] inp:", inp)
print("[DEBUG] type(inp):", type(inp))
print("[DEBUG] inp.shape:", inp.shape)
try:
print("[DEBUG] inp.shape.rank:", inp.shape.rank)
except Exception as e:
print("[DEBUG] could not read rank →", e)
print("[DEBUG] --------------------------------------------------")
out = tfpl.DenseFlipout(16)(inp) # ← AttributeError: tuple has no attribute “rank”
tf.keras.Model(inp, out)
< /code>
output: < /p>
[DEBUG] inp:
[DEBUG] type(inp):
[DEBUG] inp.shape: (None, 10)
[DEBUG] could not read rank → 'tuple' object has no attribute 'rank'
[DEBUG] --------------------------------------------------
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 13
11 print("[DEBUG] could not read rank →", e)
12 print("[DEBUG] --------------------------------------------------")
---> 13 out = tfpl.DenseFlipout(16)(inp) # ← AttributeError: tuple has no attribute “rank”
14 tf.keras.Model(inp, out)
File ~\AppData\Roaming\Python\Python39\site-packages\tf_keras\src\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs)
67 filtered_tb = _process_traceback_frames(e.__traceback__)
68 # To get the full stack trace, call:
69 # `tf.debugging.disable_traceback_filtering()`
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
File ~\AppData\Roaming\Python\Python39\site-packages\tf_keras\src\engine\input_spec.py:251, in assert_input_compatibility(input_spec, inputs, layer_name)
244 raise ValueError(
245 f'Input {input_index} of layer "{layer_name}" '
246 "is incompatible with the layer: "
247 f"expected max_ndim={spec.max_ndim}, "
248 f"found ndim={ndim}"
249 )
250 if spec.min_ndim is not None:
--> 251 ndim = x.shape.rank
252 if ndim is not None and ndim < spec.min_ndim:
253 raise ValueError(
254 f'Input {input_index} of layer "{layer_name}" '
255 "is incompatible with the layer: "
(...)
258 f"Full shape received: {tuple(shape)}"
259 )
AttributeError: 'tuple' object has no attribute 'rank'
Подробнее здесь: https://stackoverflow.com/questions/795 ... neural-net
Тупел не имеет ошибки атрибута "ранга" при попытке построить байесовскую нейронную сеть ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Тупел не имеет ошибки атрибута "ранга" при попытке построить байесовскую нейронную сеть
Anonymous » » в форуме Python - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Тупел не имеет ошибки атрибута "ранга" при попытке построить байесовскую нейронную сеть
Anonymous » » в форуме Python - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Эй, ребята, пытаясь построить сверточную нейронную сеть, используя Python с нуля
Anonymous » » в форуме Python - 0 Ответы
- 20 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Эй, ребята, пытаясь построить сверточную нейронную сеть, используя Python с нуля
Anonymous » » в форуме Python - 0 Ответы
- 14 Просмотры
-
Последнее сообщение Anonymous
-