tensorflow2.0訓練報數據輸入錯誤Failed to find data adapter

1 問題描述:

運行如下訓練代碼:

import numpy as np

history = classifier.fit(x_train, y_train,

                    batch_size=10,

                    epochs=100,

                    validation_data=(x_test, y_test))

報錯:

ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, <class 'pandas.core.series.Series'>

 

2 分析問題:

Beein搜索:

https://stackoverflow.com/questions/59643614/valueerror-failed-to-find-data-adapter-that-can-handle-input-class-numpy-nda

其中提到很可能是沒有將數據轉爲numpy。

於是我們檢查數據類型:

發現y_test的數據類型確實不是numpy。

 

3 解決問題:

將y_test轉爲numpy類型的數據:

4 擴展

model.fit()參數:    

https://keras-cn.readthedocs.io/en/latest/models/model/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章