Hi, I've been trying to use BERT from kaggle and it's not working for me. I hope this is the right channel to post this. I am trying to use BERT for text classification. Pardon me if I make mistakes, I'm very new to NLP. I've used exactly the example code on kaggle with a softmax dense layer:
text_input = tf.keras.layers.Input(shape=(), dtype=tf.string)
preprocessor = hub.KerasLayer(
"https://kaggle.com/models/tensorflow/bert/frameworks/TensorFlow2/variations/en-uncased-preprocess/versions/3")
encoder_inputs = preprocessor(text_input)
encoder = hub.KerasLayer(
"https://www.kaggle.com/models/tensorflow/bert/frameworks/TensorFlow2/variations/bert-en-uncased-l-10-h-128-a-2/versions/2",
trainable=True)
outputs = encoder(encoder_inputs)
l = tf.keras.layers.Dropout(0.1, name="dropout")(outputs['pooled_output'])
l = tf.keras.layers.Dense(4, activation='softmax', name="output")(l)
model = tf.keras.Model(inputs=[text_input], outputs = [l])
I'm running this in a kaggle notebook. I get the following error by simply running the cell:```
ValueError: A KerasTensor is symbolic: it's a placeholder for a shape an a dtype. It doesn't have any actual numerical value. You cannot convert it to a NumPy array.``` Thank you!
I have tried disabling tensorflow eager execution and it still gives me the same error.