-
-
Notifications
You must be signed in to change notification settings - Fork 676
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
Attention Mechanism not working #56
Comments
Try to downgrade your tensorflow version. |
I changed the way I was defining the model, without downgrading Tensorflow and it started working again. New model definition:
|
Great! |
Quick follow-up question: Can you tell how to downgrade tensorflow to 2.3? Current version in Colab is 2.5 and I am having the reported issue again, even with the new model definition. |
Alright, so that worked. Next up, I cannot use multiple Attention layers in one ensembled model. So, I have model1 that has an attention layer and I have model2 that has another attention layer. But when I concatenate these two models, I get this error: |
@SaharaAli16 yes have to remove the names inside the layers: https://github.com/philipperemy/keras-attention-mechanism/blob/0f8b440e8e74fb25309b2d391f7280bf4f13129a/attention/attention.py#L24. Otherwise Keras will complain that they already exist if you instantiate a second Attention class. |
The suggested setup:
No longer works for TF 2.7.0 Error :
|
I would suggest copying the source code and compile it in your code. That should work. |
Yes so this issue was fixed in the latest release (4.1) of the attention mechanism.
Will solve it. |
Hi,
I have added an attention layer (following the example) to my simple LSTM network shown below.
timestep = timesteps
features = 11
model = Sequential()
model.add(LSTM(64, input_shape=(timestep,features), return_sequences=True))
model.add(Dropout(0.2))
model.add(LSTM(32, return_sequences=True))
model.add(LSTM(16, return_sequences=True))
model.add(Attention(32))
model.add(Dense(32))
model.add(Dense(16))
model.add(Dense(1))
print(model.summary())
The code worked fine up till last week and I got a summary of model having attention layer details like this:
However, now running the same code gives me a weird error.
ValueError: tf.function-decorated function tried to create variables on non-first call.
What I noticed is that the model summary has changed too:
![image](https://user-images.githubusercontent.com/61421364/119895129-6bdb1f00-bf0b-11eb-9ca9-3fd20a70869d.png)
I am tight on time due an upcoming deadline. Any assistance would be highly appreciated.
P.S. This was a fully working model that has stopped working all of a sudden for no apparent reason.
The text was updated successfully, but these errors were encountered: