Reputation: 5467
I have a deep learning model that uses BERT layer from Huggingface library (TF=2.0
, Transformers=2.8.0
).
The model consists of: BERT embeddings -> Attention -> Softmax. Also I am using tf.keras.callbacks.ModelCheckpoint
to save the best model during training.
I'm trying to slice the model to get the attention weights.
My problem is that, if I try to access the output of any layer after loading the saved model using output1 = model.layers[3].output
, I get this error:
AttributeError: Layer tf_bert_model has no inbound nodes.
but if I do the same on the original model without saving it (instantly after finishing model.fit()), I have no problem.
This is how I load the saved model:
model = tf.keras.models.load_model(model_dir)
Is there a problem with this way?, giving that it works for prediction.
Upvotes: 1
Views: 302
Reputation:
Answering here for the benefit of the community since the user has already found the solution.
Issue was resolved by following steps
Upvotes: 1