expected dense to have shape but got array with shape

廉价感情. 提交于 2019-12-01 16:02:57

x_data is 2-dimensional array with shape (15, 100)

  print(x_data.shape) 

but x_data[0] is 1-dimensional array with shape (100, )

  print(x_data[0].shape) 

and it makes problem.

Use slicing x_data[0:1] to get it as 2-dimensional array with shape (1, 100)

 print(x_data[0:1].shape) 

and it will work

 predictions = model.predict(x_data[0:1])

Change predictions = model.predict(x_data) to predictions = model.predict(x_data[0:1])

Your input layer in your NN had 100 neurons but it seems that your input has a shape of only (1,), therefore you need change the input shape

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!