Solution for Error “Cast string to float is not supported” on training a binnary classifier Tensorflow?
is Given Below:
I am trying to build a binary classifier using neural networks but when I try to start the training the following error appears:
UnimplementedError: Cast string to float is not supported [[node binary_crossentropy/Cast (defined at <ipython-input-40-be0cf804469b>:7) ]] [Op:__inference_train_function_963] Function call stack: train_function
This is the function that I am using to creat the Neural Network:
def build_model_1(): model = keras.Sequential([ layers.Dense(neuronas, activation='relu', input_shape=[size]), layers.Dense(neuronas, activation='relu'), layers.Dense(neuronas, activation='relu'), layers.Dense(neuronas, activation='softmax'), layers.Dense(2) ]) model.compile(loss="binary_crossentropy", optimizer="adam", metrics=['accuracy']) return model neuronas = 32 model_1 = build_model_1() model_1.summary()
To obtain the sets for the lable and the training data I am using
from sklearn.model_selection import train_test_split train, test, lab_train, lab_test = train_test_split(flifghts_features, flights_lable, test_size=0.20, random_state=27121992)