tensorflow2.0训练报数据输入错误Failed to find data adapter

1 问题描述:

tensorflow2.0训练报数据输入错误Failed to find data adapter

运行如下训练代码:

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://*.com/questions/59643614/valueerror-failed-to-find-data-adapter-that-can-handle-input-class-numpy-nda

tensorflow2.0训练报数据输入错误Failed to find data adapter

其中提到很可能是没有将数据转为numpy。

于是我们检查数据类型:

tensorflow2.0训练报数据输入错误Failed to find data adapter

发现y_test的数据类型确实不是numpy。

 

3 解决问题:

将y_test转为numpy类型的数据:

tensorflow2.0训练报数据输入错误Failed to find data adapter

4 扩展

model.fit()参数:    

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