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

keras==3.7.0 - Attention(... return_attention_scores=True) does not work #20680

Closed
Furkan-rgb opened this issue Dec 23, 2024 · 2 comments
Closed
Assignees

Comments

@Furkan-rgb
Copy link
Contributor

Furkan-rgb commented Dec 23, 2024

With keras==3.7.0, the following snippet:

import keras
from keras import layers

attention = layers.Attention()

x = keras.Input(shape=(3, 5))
y = keras.Input(shape=(3, 5))

out_attn, out_attn_scores = attention(x, y, return_attention_scores=True)

Throws:

Traceback (most recent call last):
  File "attention_repro.py", line 10, in <module>
    out_attn, out_attn_scores = attention(x, y, return_attention_scores=True)
  File "venv\lib\site-packages\keras\src\backend\common\keras_tensor.py", line 121, in __iter__
    raise NotImplementedError(
NotImplementedError: Iterating over a symbolic KerasTensor is not supported.

Because return_attention_scores seems to have no effect, and the second output is not returned. The attention.call() method seems right, it's just that the call doesn't seem to construct the output tuple correctly.

@Furkan-rgb
Copy link
Contributor Author

It is the exact same issue as #19303

@Furkan-rgb
Copy link
Contributor Author

Fixed #20684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants