美文网首页
AttributeError: 'str' object has

AttributeError: 'str' object has

作者: JeremyL | 来源:发表于2019-12-31 20:39 被阅读0次

    fit输入数据需要时numpy array
    原文见 Keras AttributeError: 'list' object has no attribute 'ndim'

    model.fit expects x and y to be numpy array. Seems like you pass a list, it tried to get shape of input by reading ndim attribute of numpy array and failed.

    解决办法:使用np.array()

    import numpy as np
    ...
    model.fit(np.array(train_X),np.array(train_Y), epochs=20, batch_size=10)
    

    相关文章

      网友评论

          本文标题:AttributeError: 'str' object has

          本文链接:https://www.haomeiwen.com/subject/ekuioctx.html