Skip to content
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

bert_nlu_basic_api.py does not work with Trans Model #19

Closed
redrussianarmy opened this issue Oct 2, 2020 · 1 comment
Closed

bert_nlu_basic_api.py does not work with Trans Model #19

redrussianarmy opened this issue Oct 2, 2020 · 1 comment

Comments

@redrussianarmy
Copy link
Contributor

Hello there,
I have trained a trans model. When I want to run bert_nlu_basic_api.py file, it does not work. Then, I realized that the Trans model classes are not imported in the file. I have imported the JointTransBertModel class and loaded the model with JointTransBertModel.load(load_folder_path) in bert_nlu_basic_api.py At the end, I have got following error:

ValueError: Unknown layer: Custom>TFBertMainLayer

Traceback (most recent call last):

  File "bert_nlu_basic_api.py", line 105, in <module>
    initialize()
  File "bert_nlu_basic_api.py", line 46, in initialize
    model = JointTransBertModel.load(load_folder_path)
  File "/home/hakan/Documents/HB/dialog-nlu/models/joint_trans_bert.py", line 42, in load
    return BaseJointTransformerModel.load_model_by_class(BaseJointTransformerModel, load_folder_path, 'joint_bert_model.h5')
  File "/home/hakan/Documents/HB/dialog-nlu/models/base_joint_trans.py", line 121, in load_model_by_class
    new_model.model = tf.keras.models.load_model(os.path.join(load_folder_path, trans_model_name))
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/saving/save.py", line 182, in load_model
    return hdf5_format.load_model_from_hdf5(filepath, custom_objects, compile)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/saving/hdf5_format.py", line 178, in load_model_from_hdf5
    custom_objects=custom_objects)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/saving/model_config.py", line 55, in model_from_config
    return deserialize(config, custom_objects=custom_objects)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 175, in deserialize
    printable_module_name='layer')
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 358, in deserialize_keras_object
    list(custom_objects.items())))
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/engine/functional.py", line 617, in from_config
    config, custom_objects)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/engine/functional.py", line 1204, in reconstruct_from_config
    process_layer(layer_data)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/engine/functional.py", line 1186, in process_layer
    layer = deserialize_layer(layer_data, custom_objects=custom_objects)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/layers/serialization.py", line 175, in deserialize
    printable_module_name='layer')
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 347, in deserialize_keras_object
    config, module_objects, custom_objects, printable_module_name)
  File "/home/hakan/.local/share/virtualenvs/dialog-nlu-TCo_F89F/lib/python3.6/site-packages/tensorflow/python/keras/utils/generic_utils.py", line 296, in class_and_config_for_serialized_keras_object
    raise ValueError('Unknown ' + printable_module_name + ': ' + class_name)
ValueError: Unknown layer: Custom>TFBertMainLayer
@MahmoudWahdan
Copy link
Owner

Hi @redrussianarmy
Since Trans models is a new feature, it is not supported in bert_nlu_basic_api.py till now.
I added a new feature request #20 to add support for joint trans models in the basic api script.
Please, note that bert_nlu_basic_api.py is just a maple basic api that wraps the model. In the production you may need to do more than the basic api.

I'll close the issue and please watch the dedicated feature request #20 for the status.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants