ORIGINALLY, THIS IS THE ERROR
ValueError Traceback (most recent call last)
<ipython-input-59-fad2403f8088> in <cell line: 4>()
2 x1=tf.keras.layers.Input((512),name='question',dtype='int64')
3 x2=tf.keras.layers.Input((512),name='question_mask',dtype='int64')
----> 4 q_embed=medical_qa_model.get_layer('q_ffn')(medical_qa_model.get_layer('tf_bert_model').bert(input_ids=x1,attention_mask=x2,).pooler_output)
5 question_extractor_model=tf.keras.Model(inputs=[x1,x2],outputs=q_embed)
/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py in get_layer(self, name, index)
3565 if layer.name == name:
3566 return layer
-> 3567 raise ValueError(
3568 f"No such layer: {name}. Existing layers are: "
3569 f"{list(layer.name for layer in self.layers)}."
ValueError: No such layer: tf_bert_model. Existing layers are: ['q_ffn', 'a_ffn', 'dot_6'].
THEN WE TRIED TO FIX IT BY USING THIS CODE INSTEAD q_embed=medical_qa_model.get_layer(‘q_ffn’)(biobert_model.bert(input_ids=x1,attention_mask=x2).pooler_output) BUT THE ERROR IS:
TypeError Traceback (most recent call last)
<ipython-input-70-b62675cce648> in <cell line: 4>()
2 x1=tf.keras.layers.Input((512),name='question',dtype='int64')
3 x2=tf.keras.layers.Input((512),name='question_mask',dtype='int64')
----> 4 q_embed=medical_qa_model.get_layer('q_ffn')(biobert_model.bert(input_ids=x1,attention_mask=x2,).pooler_output)
5 question_extractor_model=tf.keras.Model(inputs=[x1,x2],outputs=q_embed)
6 frames
/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py in error_handler(*args, **kwargs)
68 # To get the full stack trace, call:
69 # tf.debugging.disable_traceback_filtering()
---> 70 raise e.with_traceback(filtered_tb) from None
71 finally:
72 del filtered_tb
TypeError: Exception encountered when calling layer 'embeddings' (type TFBertEmbeddings).
Could not build a TypeSpec for name: "tf.debugging.assert_less_2/assert_less/Assert/AssertGuard/Identity"
op: "Identity"
input: "tf.debugging.assert_less_2/assert_less/Assert/AssertGuard"
attr {
key: "T"
value {
type: DT_BOOL
}
}
of unsupported type <class 'tensorflow.python.framework.ops.Operation'>.
Call arguments received by layer 'embeddings' (type TFBertEmbeddings):
• input_ids=<KerasTensor: shape=(None, 512) dtype=int64 (created by layer 'question')>
• position_ids=None
• token_type_ids=<KerasTensor: shape=(None, 512) dtype=int32 (created by layer 'tf.fill_2')>
• inputs_embeds=None
• past_key_values_length=0
• training=False
and when I try to display medical_qa_model this is the error we encounter
ValueError Traceback (most recent call last)
<ipython-input-58-96c95019b090> in <cell line: 1>()
----> 1 medical_qa_model.summary()
/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py in summary(self, line_length, positions, print_fn, expand_nested, show_trainable, layer_range)
3504 """
3505 if not self.built:
-> 3506 raise ValueError(
3507 "This model has not yet been built. "
3508 "Build the model first by calling build() or by calling "
ValueError: This model has not yet been built. Build the model first by calling build() or by calling the model on a batch of data.
Jessa Lorenza Sabas is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.