Comments (14)
Which version of tensorflow are you using? Update your tensorflow.
from keras-attention.
I have tensorflow 2.3.0.
For example, at the end of your example (example-attention.py ) after "model.fit" I wrote:
model.fit(x_train, y_train, validation_data=(x_val, y_val), epochs=max_epoch,
batch_size=64, callbacks=[VisualiseAttentionMap()])
#What I wrote
model.save('test_model.h5')
modelh5 = load_model('test_model.h5', custom_objects={'Attention': Attention})
Error I get:
File "C:\Users\edith\anaconda3\lib\site-packages\tensorflow\python\keras\layers\merge.py", line 663, in build
raise ValueError('A Dot
layer should be called '
ValueError: A Dot
layer should be called on a list of 2 inputs.
I am attaching a picture of the script where I try to save and load the model
Thank you very much for your help and time!
from keras-attention.
Good catch I think we need to use Dot
instead of dot
.
from keras-attention.
Hum still does not work and not sure why:
from keras-attention.
@edithangelicar save
can sometimes be very tricky. I advise you to use load_weights
and save_weights
instead:
You will have to re-define your model and instanciate your model beforehand but I don't see any other solutions in the short term.
model.save_weights('test_model.h5')
model = <bla bla>
model.load_weights('test_model.h5')
from keras-attention.
Thank you for checking and for your help!
If at some point you get to know how to solve the problem, please let me know.
Thank you!
from keras-attention.
I think I managed, you have to change your model from sequential to functional API. Thank you!
from keras-attention.
Have literally just hit this issue myself; thanks for the comments and update.
from keras-attention.
Nickion, also remember to create the get_config and from_config in the class: https://keras.io/guides/serialization_and_saving/
from keras-attention.
Great @edithangelicar can you provide a small snippet to show how to get it to work?
from keras-attention.
yes. here are some pictures, it is lightly modified for fitting what I am doing so it doesn't correspond exactly to your example.
from keras-attention.
@edithangelicar can you paste it here instead of pictures? It will be easier for others to understand it.
from keras-attention.
I am attaching txt since here I can't paste python files
functional_lstm.txt
attention.txt
from keras-attention.
Alright thanks!
from keras-attention.
Related Issues (20)
- Hiddent state parameter, what really should be passed? HOT 1
- pip install and numpy, keras packages are forced to be uninstalled HOT 1
- Use this repository for CNN HOT 1
- 2D attention HOT 6
- weird attention weights when adding sequence of numbers. HOT 1
- attention when using more than one feature HOT 1
- Using attention with multivariate timeseries data
- Loading model problems HOT 5
- Interpreting attention weights for more than one input features. HOT 2
- Add guidance to README to use Functional API for saving models that use this layer HOT 4
- Attention Mechanism not working HOT 10
- what do the h_t mean in the Attention model? HOT 1
- Output with multiple time steps HOT 1
- Attention not working for MLP HOT 2
- TypeError: Expected `trainable` argument to be a boolean, but got: 64 HOT 3
- Please update version HOT 1
- TypeError: __call__() takes 2 positional arguments but 3 were given HOT 2
- Number of parameters in Attention layer HOT 2
- Does it support causal mask? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras-attention.