top of page

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 All

[Python] Output pandas.DataFrame as json

Summary Data analysis is performed using python. The analysis itself is performed using pandas, and the final results are stored in pandas.DataFrame format. I want to output this result to a file in j

[Python] Conditionally fitting

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 cases where you want to condition the fitting parameters. For

Comments


Let's do our best with our partner:​ ChatReminder

iphone6.5p2.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Let's do our best with our partner:​ ChatReminder

納品:iPhone6.5①.png

It is an application that achieves goals in a chat format with partners.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png

Theme diary: Decide the theme and record for each genre

It is a diary application that allows you to post and record with themes and sub-themes for each genre.

google-play-badge.png
Download_on_the_App_Store_Badge_JP_RGB_blk_100317.png
bottom of page