'How do I fit a model in Keras after getting Train and test set from Sklearn

I'm pretty new to machine learning and I am trying to figure out how I would feed in data to a model after I get the train test split from Sklearn. Right now this is what I have in the data preparation phase.

x_train, x_test, y_train, y_test =train_test_split(db[predictors], db["default.payment.next.month"], test_size=.2)
x_train= x_train.to_numpy()
x_test = x_test.to_numpy()
y_train = y_train.to_numpy()
y_test = y_test.to_numpy()

I set them all the numpys which I thought was necessary to plug into the model.fit() function. My model.fit() function looks like this:

history = model.fit(x_train, 
                   y_train, 
                   epochs=20, 
                   batch_size=512,
                   validation_data=(x_val, y_val))

and then I get an error like this:

ValueError: Input 0 of layer "sequential_5" is incompatible with the layer: expected shape=(None, 10000), found shape=(None, 5)

Is there something I'm missing or doing wrong?



Solution 1:[1]

As error shows, try using input_shape as below:

model.add(layers.Dense(16, activation = 'relu', input_shape=(5,))) 

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TFer2