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
Runtime error "shape5_variable needs to be an array" #181
Comments
Thanks for pointing that out explicitly, because that's an important hint to not look for the error in frugally-deep but in the setup of the machine, you are using. Maybe it has something to do with virtualenv? I'd first try to re-install Keras and TensorFlow: sudo pip3 uninstall Keras
sudo pip3 uninstall TensorFlow
sudo pip3 install Keras
sudo pip3 install TensorFlow and see how that goes. Then try to run some minimal Keras examples in Python on that machine, i.e., nothing frugally-deep related, to reduce complexity of this test. Something like that: import numpy as np
from keras.layers import Input, Dense
from keras.models import Model
inputs = Input(shape=(4,))
x = Dense(5, activation='relu')(inputs)
predictions = Dense(3, activation='softmax')(x)
model = Model(inputs=inputs, outputs=predictions)
model.compile(loss='categorical_crossentropy', optimizer='nadam') If you have that working, try again with frugally-deep. Oh, and would using Docker be an option for you? 😁 |
Thank you. My python3 was broken and I had to start from installing back pip3, and then keras and TensorFlow. Above example works fine, there were lot of warnings, but I printed model.summary() at the end so that we know it actually works for me. I was now able to I am sorry, but I don't know if Docker would help me much, as I am working on linking frugally-deep with another library which is huge and based on CPP. |
Could you upload your model ( |
Mhh, it might be that it does not help that much, because likely my machine is one them those, where the application just works. Could you try to
Maybe this helps. |
Yes, I think because on my other machine everything is fine. I tried all of your suggestions, but nothing seems to work. I realized I was using an older version of g++(5), and upgraded it to g++-7, thought this might be the issue but it is not. However, while converting my model from h5 to json there were some additional warnings, not seen of my other machine: This could be a hint of what is wrong here on my system. The whole log file for converting model |
Could you upload the following?
|
The files are here: Certainly, by comparing both file there is a difference in converting from h5 to json. The warning: came as tf is having some issues with higher versions of numpy (1.17). They have discussed this issue here and added a solution here . Edit: |
But I just tested here in C++. I get the Then I tried to convert
The Could you create a minimal Python code, that builds this model architecture? |
The machine which works fine has frugally-deep and other packages installed on June 21. The one which I am working now has an installation of today's version of frugally-deep.
The model is generated by another team working on it, I have the generated model only. I will ask them if they could provide the code to be shared. The model is perfectly fine and working on the other machine. I am sure of that. Maybe I should be using the older version of frugally-deep? |
Alrighty.. I had the older version of frugally-deep and other packages. I have just built and tested the same code and model for both machines and they both work the same now. Here is the code for generating model: |
That might be a short-term workaround. However, you will be doomed to use the old version forever and will not be able to benefit from possible advances in later versions. I would very much prefer to find out why the latest version can not handle the model.
Thank would be great. Thanks. 🙂 |
Thanks for sending over the code, which creates the model architecture. As discussed, I'll not publish it here. But I was able to reduce it to a minimal example, that reproduces the problem fully but does not disclose secrets. So, the following model from keras.layers import LSTM
from keras.models import Sequential
model = Sequential()
model.add(LSTM(units=10, activation="relu", return_sequences=True, input_shape=(1, 10)))
model.compile(loss='categorical_crossentropy', optimizer='nadam')
model.save('fdeep_issue_181.h5') Also results in
when trying to convert it with the latest frugally-deep version. I'll check if I can fix this and get back to you here. |
OK, one way to make it work, is to express the same architecture not with the sequential interface of Keras, but with the functional API instead. from keras.layers import Input, LSTM
from keras.models import Model
inputs = Input(shape=(1, 10))
outputs = LSTM(units=10, activation="relu", return_sequences=True)(inputs)
model = Model(inputs=inputs, outputs=outputs)
model.compile(loss='categorical_crossentropy', optimizer='nadam')
model.save('fdeep_issue_181_functional.h5') So if you need a quick workaround, you can just do this and should be fine. Nevertheless, I'll check why the sequential version behaves differently. |
The problem was in the conversion from sequential models to functional ones, that frugally-deep does internally. Thanks for reporting the issue and helping debug it with your example. |
Thank you. |
I have successfully installed frugally-deep as shown in INSTALL.md.
I compiled a small CPP application to test installation (same code is tested on another machine running frugally-deep), but while running gave error
Loading json ... done. elapsed time: 0.012854 s terminate called after throwing an instance of 'std::runtime_error' what(): shape5_variable needs to be an array Aborted (core dumped)
This is the complete output of error log.
Also, I couldn't do the last step of INSTALL.md
make unnitest
gives error
Traceback (most recent call last): File "/home/code/DIAMLER_PROJECT/KERAS/frugally-deep/keras_export/generate_test_models.py", line 7, in <module> import keras ImportError: No module named 'keras' test/CMakeFiles/test_model_full_test_data.dir/build.make:64: recipe for target 'test/test_model_full.h5' failed make[3]: *** [test/test_model_full.h5] Error 1 CMakeFiles/Makefile2:577: recipe for target 'test/CMakeFiles/test_model_full_test_data.dir/all' failed make[2]: *** [test/CMakeFiles/test_model_full_test_data.dir/all] Error 2 CMakeFiles/Makefile2:138: recipe for target 'test/CMakeFiles/unittest.dir/rule' failed make[1]: *** [test/CMakeFiles/unittest.dir/rule] Error 2 Makefile:173: recipe for target 'unittest' failed make: *** [unittest] Error 2
For some reason, keras is not getting called from python (I have already installed tensorflow, keras and related packages, I am working on the python side of the error), but this could not have been related to building cpp application (I thought so).\
The same application works a charm on other systems.
The text was updated successfully, but these errors were encountered: