johnsmithm / multi-heads-attention-image-classification Goto Github PK
View Code? Open in Web Editor NEWMulti heads attention for image classification
Multi heads attention for image classification
Inside the definition of MultiHeadsAttModel
function, the dimension of att
variable turns out to be (l, dv, dv)
and not (l, nv, nv)
as mentioned with the output_shape
parameter.
output_shape
itself is not relevant with tensorflow backend hence it does not raise an error, and I am able to reproduce the results. However, I am not sure if the shape of att
variable was intended to be (l, nv, nv)
?
Hey I tried implementing your model.... but I could get an accuracy of just 0.0987.
What is the error?
I can't save the keras model by calling model.save(model_path) where model is a keras model and model_path is the directory.
If I remove the attention block, then everything will be back to normal.
Though tensorflow saver does work, is there any way I can have a .h5 keras model?
There's a batch dot error that shows at Line 34, axes given 4,3 that's out of range error. It should be 3,2 with the given arrays as [64, 8, 8] and [64, 8, 64].
After resolving tabove error, I am getting a Reshape error. Model summary prints fine. The error is :
Traceback (most recent call last):
File "multi-heads-attention-mnist.py", line 121, in <module>
validation_data=(X_test, Y_test)
File "/home/intern_akash/akash_hpc/lib/python3.6/site-packages/keras/engine/training.py", line 1239, in fit
validation_freq=validation_freq)
File "/home/intern_akash/akash_hpc/lib/python3.6/site-packages/keras/engine/training_arrays.py", line 196, in fit_loop
outs = fit_function(ins_batch)
File "/home/intern_akash/akash_hpc/lib/python3.6/site-packages/tensorflow/python/keras/backend.py", line 3292, in __call__
run_metadata=self.run_metadata)
File "/home/intern_akash/akash_hpc/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1458, in __call__
run_metadata_ptr)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Input to reshape is a tensor with 1146617856 values, but the requested shape has 884736
[[{{node model_1/reshape_5/Reshape}}]]
[[metrics/accuracy/Identity/_243]]
(1) Invalid argument: Input to reshape is a tensor with 1146617856 values, but the requested shape has 884736
[[{{node model_1/reshape_5/Reshape}}]]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.