A story about an error when loading a TensorFlow model created with Google Colab locally

environment

Google Colab environment

Python3.6.9 TensorFlow2.3.0

Local environment

Python3.6.7 TensorFlow2.1.0

what's happened?

Download the model created by Google Colab and When I tried to run it in the local environment, I got angry when TesorFlow was imported.

ʻImportError: DLL load failed: The specified module cannot be found `

Microsoft Visual C ++ Redistributable required from TensorFlow 2.1

After investigating, it seems that Microsoft Visual C ++ Redistributable is required from TensorFlow 2.1. Install from the following URL. https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads

This is the solution! However, I encounter an error again.

I was able to import, but when I loaded the model, I got an error saying KeyError:'sample_weight_mode.

I tried to load the model with the following code ...

from tensorflow.keras.models import load_model
new_model = load_model(r'***.h5')

A message like ↓ is displayed and cannot be read. KeyError: 'sample_weight_mode'

Once again, thanks to Google Sensei, There was a person with the exact same phenomenon in an overseas forum. https://github.com/keras-team/keras/issues/14040

According to this article, it seems that an error will occur when trying to load a model created with TensorFlow 2.3 with a lower version.

When I raised TensorFlow in my local environment to 2.3, it loaded successfully. (The command is below)

pip install tensorflow==2.3.0

Recommended Posts

A story about an error when loading a TensorFlow model created with Google Colab locally
A story about installing matplotlib using pip with an error
What to do if an error occurs when loading a python project created with poetry into VS Code
A memorandum when an error occurs with pip install
A story about how Windows 10 users created an environment to use OpenCV3 with Python 3.5
About learning with google colab
A story about an amateur making a breakout with python (kivy) ②
A story about an amateur making a breakout with python (kivy) ①
A story about a war when two newcomers developed an app
A story about machine learning with Kyasuket
When I get an error with PyInstaller
Try TensorFlow RNN with a basic model
If you get a long error when tabbing an interactive shell with Anaconda
A story about making an x86 bootloader that can boot vmlinux with Rust
A addictive story when using tensorflow on Android
I got an error when saving with OpenCV
A story about simple machine learning using TensorFlow
A story about implementing a login screen with django
Rollback processing when an error occurs with fabric
Cheat sheet when scraping with Google Colaboratory (Colab)
A story about making 3D space recognition with Python
A story about using Resona's software token with 1Password
A story about predicting exchange rates with Deep Learning
A story about making Hanon-like sheet music with Python
When writing an if statement with a regular expression
A story about how theano was moved with TSUBAME 2.0
A story linked with Google Cloud Storage with a little ingenuity
I got an error when using Tensorboard with Pytorch
(First post) A story about numerical calculation of influenza and new pneumonia coronavirus with Tensorflow
A story about developing a machine learning model while managing experiments and models with Azure Machine Learning + MLflow