[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: as_list() is not defined on an unknown TensorShape. during training #68217

Open
guillaumelorre28 opened this issue May 18, 2024 · 3 comments
Assignees
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.16 type:bug Bug

Comments

@guillaumelorre28
Copy link

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

2.17.0-dev20240517

Custom code

Yes

OS platform and distribution

macOS Sonoma

Mobile device

No response

Python version

3.10.13

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

I get the following error when training a transformer for translation:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[9], [line 6](vscode-notebook-cell:?execution_count=9&line=6)
      [1](vscode-notebook-cell:?execution_count=9&line=1) model.compile(optimizer='adam', 
      [2](vscode-notebook-cell:?execution_count=9&line=2)     loss='sparse_categorical_crossentropy', 
      [3](vscode-notebook-cell:?execution_count=9&line=3)     metrics=['accuracy'],
      [4](vscode-notebook-cell:?execution_count=9&line=4)     run_eagerly=False
      [5](vscode-notebook-cell:?execution_count=9&line=5)     )
----> [6](vscode-notebook-cell:?execution_count=9&line=6) model.fit(dataset_train, epochs=10)

File ~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122, in filter_traceback.<locals>.error_handler(*args, **kwargs)
    [119](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:119)     filtered_tb = _process_traceback_frames(e.__traceback__)
    [120](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:120)     # To get the full stack trace, call:
    [121](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:121)     # `keras.config.disable_traceback_filtering()`
--> [122](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:122)     raise e.with_traceback(filtered_tb) from None
    [123](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:123) finally:
    [124](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py:124)     del filtered_tb

File ~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/optree/ops.py:594, in tree_map(func, tree, is_leaf, none_is_leaf, namespace, *rests)
    [592](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/optree/ops.py:592) leaves, treespec = _C.flatten(tree, is_leaf, none_is_leaf, namespace)
    [593](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/optree/ops.py:593) flat_args = [leaves] + [treespec.flatten_up_to(r) for r in rests]
--> [594](https://file+.vscode-resource.vscode-cdn.net/Users/glo/Desktop/deep_learning_training-main/~/opt/anaconda3/envs/tensorflow_latest/lib/python3.10/site-packages/optree/ops.py:594) return treespec.unflatten(map(func, *flat_args))

ValueError: as_list() is not defined on an unknown TensorShape.

Standalone code to reproduce the issue

Here is a colab link to the code:
https://colab.research.google.com/drive/1BQ4lhaZPP5XGb_IUe-rVacMiFPWCfm9Y?usp=sharing

Running eagerly works fine but an error occurs in graph mode.

Relevant log output

No response

@google-ml-butler google-ml-butler bot added the type:bug Bug label May 18, 2024
@SuryanarayanaY SuryanarayanaY added subtype:macOS macOS Build/Installation issues TF 2.16 labels May 21, 2024
@SuryanarayanaY
Copy link
Collaborator

Hi @guillaumelorre28 ,

I have reproduced the reported issue.Attached gist for same.

@tilakrayal
Copy link
Contributor

@guillaumelorre28,
Looks like the custom layer sub classed from LSTM layer has a problem when loading in .keras format but with .tf format it is working fine. The problem exists in tf-nightly also.

Also there is an issue for the same error which is still open and assigned to the Developer. Could you please check and follow the same for the updates.

#61270

Thank you!

@tilakrayal tilakrayal added stat:awaiting response Status - Awaiting response from author comp:keras Keras related issues and removed subtype:macOS macOS Build/Installation issues labels Jun 14, 2024
Copy link

This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:keras Keras related issues stale This label marks the issue/pr stale - to be closed automatically if no activity stat:awaiting response Status - Awaiting response from author TF 2.16 type:bug Bug
Projects
None yet
Development

No branches or pull requests

3 participants