-
Notifications
You must be signed in to change notification settings - Fork 108
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
Anyone managed to get this to work with saved model? #4
Comments
Did you try to run the following code instead?
|
I can't load the model: new_model = keras.models.load_model('Sentiment_Classification_model_smallsiwetest.h5') File "", line 1, in File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/saving.py", line 453, in load_wrapper File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/saving.py", line 545, in load_model File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/saving.py", line 243, in _deserialize_model File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/saving.py", line 588, in model_from_config File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/layers/init.py", line 168, in deserialize File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 147, in deserialize_keras_object File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/network.py", line 1043, in from_config File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/engine/network.py", line 1029, in process_layer File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/layers/init.py", line 168, in deserialize File "/lib/miniconda/envs/conda-venv/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 140, in deserialize_keras_object ValueError: Unknown layer: BertLayer |
@JiahuiSophieHU have you tried instantiating the new_model = keras.models.load_model('Sentiment_Classification_model_smallsiwetest.h5',
custom_objects={'BertLayer': BertLayer}) |
I am facing a similar situation, not being able to load the saved model. @smfullman tried this, but I am getting an error saying 'Shapes (768,) and (512, 768) are incompatible'. |
@devinharia I am facing the same problem. Did you get the solution? |
@veqtor I was not able to save the model until I wrote my own get_config.py function in the BertLayer class. Adding this code to the class made it run for me: '''
''' |
I've trained a model that retunes a bertlayer but I can't seem to get it to export as a saved model properly... Any ideas?
The text was updated successfully, but these errors were encountered: