I am getting this problem called "

Node: 'Cast_1'
Cast string to float is not supported
     [[{{node Cast_1}}]] [Op:__inference_train_function_24202]

" enter image description here



I wrote a code about IMDB sentiment analysis for 5000 data in Google Colab

#importing the necessary libraries
import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.preprocessing.text import Tokenizer

#importing the data
data = pd.read_excel('/content/drive/MyDrive/499A_Project/Dataset/IMDB5000.xlsx')

#spliting the dataset into train and test
train_data, test_data = train_test_split(data, test_size = 0.3, random_state = 42)

#preprocessing the data
#tokenizng the text
tokenizer = Tokenizer()
tokenizer.fit_on_texts(data['Review'].values)

#converting the text into sequences
train_sequences = tokenizer.texts_to_sequences(train_data['Review'].values)
test_sequences = tokenizer.texts_to_sequences(test_data['Review'].values)


#padding the sequences
max_length = max([len(s.split()) for s in data['Review']])
train_padded = pad_sequences(train_sequences, maxlen = max_length)
test_padded = pad_sequences(test_sequences, maxlen = max_length)

#preparing the labels
train_labels = train_data['Sentiment'].values
test_labels = test_data['Sentiment'].values

#importing Roberta model from transformers
from transformers import TFBertForSequenceClassification

#instantiating the Roberta model
model = TFBertForSequenceClassification.from_pretrained('roberta-base')

#compiling the model
model.compile(loss = 'sparse_categorical_crossentropy',
              optimizer = 'adam',
              metrics = ['accuracy'])

#training the model
model.fit(train_padded, train_labels,
          batch_size = 32,
          epochs = 10,
          validation_data = (test_padded, test_labels))


This is the code I wrote for my dataset but it is not working and show the erros

0

There are 0 best solutions below