Keras AttributeError: 'list' object has no attribute 'ndim'

后端 未结 3 1308
名媛妹妹
名媛妹妹 2021-02-12 14:50

I\'m running a Keras neural network model in Jupyter Notebook (Python 3.6)

I get the following error

AttributeError: \'list\' object has no attrib

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-12 15:08

    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.

    You can simply transform it using np.array:

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

提交回复
热议问题