Things to watch out for when using keras on Raspberry pi
Overview
When I install keras for deep learning with Raspberry pi, I get the following error at the time of import
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
ModuleNotFoundError: No module named 'tensorflow.contrib'
Cause
The cause is that the versions of tensorflow and keras do not match. The latest version of tensorflow for Raspbian, the OS for Raspberry pi, is still 1.14 ...
I don't understand well about the version correspondence between keras and tensorflow, but I speculate that keras may have a new version because it was installed without specifying the version with pip.
Solution
Use tensorflow.keras inside tensorflow. This will not cause version dependency issues. Or rather, keras itself seems to be in this flow(マルチバックエンドKerasの終焉、tf.kerasに一本化)。
Even if you have already written the program in keras, by using the code below, you can use it almost as it is.
import tensorflow.keras as keras
I used the word "almost" because I could not use my code as it was in one point.
model=keras.models.load_model(model_name)
cause the error below.
str' object has no attribute 'decode'
This seems to be due to the new version of h5py. I solved it by downgrading h5py to 2.10.0.(reference)
Also, if you are learning in a different environment (I think there are more), you need to lower the version of tensorflow in that environment and relearn. I think that the latest tensorflow 2.x will be included if you do not specify the version on Mac, Windows, google colaboratory, etc.
Lastly
Watch out for version dependencies...
Recent Posts
See AllSummary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in...
Phenomenon I get a title error when trying to import firestore with raspberry pi. from from firebase_admin import firestore ImportError:...
Overview If you want to do fitting, you can do it with scipy.optimize.leastsq etc. in python. However, when doing fitting, there are many...
Comentários