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


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

一、总结

一句话总结:

问题原因:是没有将数据(y_train、y_test)转为numpy

 

 

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

转自或参考:tensorflow2.0训练报数据输入错误Failed to find data adapter
https://blog.csdn.net/try2find/article/details/104044456

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/

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM