![](/img/trans.png)
[英]Keras: Shuffling data using model.fit() doesn't make a change but sklearn.train_test_split() does
[英]How do I fit a model in Keras after getting Train and test set from Sklearn
我是機器學習的新手,我想弄清楚在從 Sklearn 進行火車測試拆分后如何將數據輸入 model。 現在這就是我在數據准備階段所擁有的。
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()
我將它們設置為我認為插入 model.fit() function 所必需的所有 numpy。我的 model.fit() function 看起來像這樣:
history = model.fit(x_train,
y_train,
epochs=20,
batch_size=512,
validation_data=(x_val, y_val))
然后我收到這樣的錯誤:
ValueError: Input 0 of layer "sequential_5" is incompatible with the layer: expected shape=(None, 10000), found shape=(None, 5)
我有什么遺漏或做錯了嗎?
如錯誤所示,嘗試使用input_shape
如下:
model.add(layers.Dense(16, activation = 'relu', input_shape=(5,)))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.