TypeError(‘Keyword argument not understood:’, ‘***’) in keras.models load_ model
- after training on Google colab, model.save (filepath)_ Save) and then use after saving
from keras.models import load_model model = load_model(model_file) # Error: TypeError: ('Keyword argument not understood:', 'step_dim')
- method 1: confirm whether the versions of keras and TF are different twice. Someone’s solution: I only solved it by upgrading tensorflow and keras on the local computer at the same time
pip install --upgrade tensorflow pip install --upgrade keras
What he means is the version problem. After training on Google’s colab, the model is saved locally. When it is called locally, the loading model will report an error due to the different versions of the packages in the two environments
then you can adjust the version of the local related package.
Similar to the following answer, the version when the model is saved is inconsistent with the version when the model is loaded, which may cause this problem
then unify the versions
import tensorflow as tf import keras print(keras.__version__) print(tf.__version__)
But mine is still read on the colab, and the environment is the same, so this method can’t solve my specific problem.
- method 2. Model.load_ Weights() only reads weights
- the general idea is that we start with models.load_ Model () reads the network and weight. Now, because of the keyword argument not understood in the custom model, we first build the model structure, and then model. Load_ Weights () reads weights, which can achieve our original purpose
- at present, I use this method to solve the problem of re reading and importing the parameters of the network structure model of the user-defined model
I also have this problem I’ve tried a lot of methods and found that this method can be used
# first,build model model = TextAttBiRNN(maxlen, max_features, embedding_dims).get_model() model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) # second, load weights: I solved the problem with this: model_file = "/content/drive/My Drive/dga/output_data/model_lstm_att_test_v6.h5" model.load_weights(model_file) # then,we will find the modle can be use. # in this way,I avoided the previous questions.
- Keras saves save() and save in the model_ weights()
- AttributeError: module…ops‘ has no attribute ‘_TensorLike‘， ValueError: `updates` argument..eager
- Solve the problem of using in tensoft 2. X tf.contrib.slim No module named appears in the package: tensorflow.contrib problem
- The function of flatten layer in deep learning
- Problem solving module ‘ tensorflow.compat . V2 ‘has no attribute’ contrib ‘and importerror cannot import name’ auto ‘
- Attributeerror: module tensorflow no attribute app solution
- “Could not import PIL.Image . The use of array_ to_ The solution of img requires PIL. “
- Solution: Failed to load the native TensorFlow runtime.
- Failed to load the native TensorFlow runtime.
- Using pip to install tensorflow: tensorflow — is not a supported wheel on this platform
- tensorflow import error: DLL load failed: The specified module could not be found (DLL load failed: The specified module could not be found)
- Tensorflow import error: DLL load failed: the specified module could not be found
- Exception ignored in: bound method basesession__ del__ Of
- To solve the problem of importerror when installing tensorflow: libcublas.so . 10.0, failed to load the native tensorflow runtime error
- ImportError: DLL load failed: The specified module could not be found
- Build your own resnet18 network and load torch vision’s own weight
- Resolve importerror: cannot import name ‘TF_ utils’
- After the model is instantiated by keras, the result returns nonetype
- Windows10解决ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed
- [Keras] ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to