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 readingndim
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)
网友评论