The issue is with y_train and y_val being a pandas Series or a DataFrame, convert it to a NumPy array to ensure compatibility with TensorFlow.
y_train = y_train.to_numpy() if hasattr(y_train, "to_numpy") else y_train
y_val = y_val.to_numpy() if hasattr(y_val, "to_numpy") else y_val