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/

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