【问题标题】:ValueError: Error when checking input: expected dense_39_input to have shape (6,) but got array with shape (1,)ValueError:检查输入时出错:预期dense_39_input的形状为(6,),但数组的形状为(1,)
【发布时间】:2019-12-16 05:25:01
【问题描述】:

这是我在 stackoverflow 上的第一篇文章。 所以我建立了一个预测 AirBnb 价格的神经网络,准确度为 77%,但我正在努力输入一个数组,以便模型可以给我一个预测。 (Jupyter 笔记本)

xa = np.array([3, 1, 1, 28, 1, 1])
print(xa.shape)
(6,)

ynew = nn3.predict(xa[0:1])
print(ynew)

在第 5 行之后出现错误

ValueError: Error when checking input: expected dense_39_input to have shape (6,) but got array with shape (1,)

使用 ynew = nn3.predict(xa) 我有同样的错误。

谢谢!

【问题讨论】:

  • 为什么是 [0:1]?你在建网络时使用了 6 个参数吗?

标签: python python-3.x machine-learning neural-network sklearn-pandas


【解决方案1】:

试试这个:

xa = numpy.array([[3, 1, 1, 28, 1, 1]])
ynew = nn3.predict(xa)
print(ynew)

【讨论】:

    猜你喜欢
    • 2020-05-30
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    • 2020-04-11
    • 2020-05-17
    • 2020-11-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多