I am doing a music artist classification using BERT in Tensor Flow. The goal is that given lyrics, the model should be able to identify the artist. My dataset is organized in a .xlsx file with three columns ('lyrics_title', 'lyrics', and 'artist') and 3479 rows.
When I pass the data frame, df, to the BERT preprocess model, I get the below error. How can I solve it? The code is provided as well, and any help will be appreciated.
#reading xlsx data into pandas dataframe
path_to_data = '/content/drive/MyDrive/AI/dataset_without_date.xlsx'
df = pd.read_excel(path_to_data)
#Getting BERT components from the url: preprocessor and encoder
preprocess_url = 'https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3'
encoder_url = 'https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/4'
#text preprocessing
bert_preprocess_model = hub.KerasLayer(preprocess_url)
text_preprocessed = bert_preprocess_model(df)
ValueError Traceback (most recent call last)
<ipython-input-18-b049c7e0f5b3> in <cell line: 3>()
1 #text preprocessing
2 bert_preprocess_model = hub.KerasLayer(preprocess_url)
----> 3 text_preprocessed = bert_preprocess_model(df)
2 frames
/usr/local/lib/python3.10/dist-packages/tensorflow_hub/keras_layer.py in <lambda>()
242 result = smart_cond.smart_cond(training,
243 lambda: f(training=True),
--> 244 lambda: f(training=False))
245
246 # Unwrap dicts returned by signatures.
ValueError: Exception encountered when calling layer 'keras_layer_1' (type KerasLayer).
Failed to convert a NumPy array to a Tensor (Unsupported object type float).
Call arguments received by layer 'keras_layer_1' (type KerasLayer):
• inputs= lyrics_title
0 god’s plan
1 in my feelings
2 hotline bling
3 one dance
4 hold on, we’re going home
... ...
3474 weak heart
3475 what could have been
3476 wish them well
3477 you can profit
3478 young tree
lyrics artist
0 and they wishin' and wishin' and wishin' and w... Drake
1 drake trap trapmoneybenny this shit got me in ... Drake
2 you used to call me on my you used to you used... Drake
3 kyla baby i like your style drake grips on y... Drake
4 produced by nineteen85 majid jordan noah 40 s... Drake
... ... ...
3474 see the writing pon the wall to those who thin... Groundation
3475 what could have been the first moment in… my d... Groundation
3476 we want to be free but not only for we jah we ... Groundation
3477 you can be, anything you want to be all of you... Groundation
3478 dem trying to cut down dem young tree don't wa... Groundation
[3479 rows x 3 columns]
• training=None