gpt4 book ai didi

python - Keras - 如何根据一个实例进行预测?

转载 作者:行者123 更新时间:2023-11-30 21:52:30 26 4
gpt4 key购买 nike

我已经创建了一个模型(h5 和 tfjs/model.json)来预测定价室。问题是我不知道如何根据一个实例进行预测?通常,根据所有测试数据进行预测。已经尝试过这个,但不起作用......

model.predict(np.array([0.347669, 0.048266, 0.515875, -0.166667, 0.000000, 0.378772]))

错误信息

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

据我所知,实例/值应该标准化(我使用线性回归)并转换为 numpy 数组。不知道如何继续。这里有一些线索,但我对此一无所知。 expected dense to have shape but got array with shape

模型摘要

Model: "sequential_1"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_1 (Dense) (None, 200) 1400
_________________________________________________________________
dense_2 (Dense) (None, 100) 20100
_________________________________________________________________
dense_3 (Dense) (None, 50) 5050
_________________________________________________________________
dense_4 (Dense) (None, 25) 1275
_________________________________________________________________
dense_5 (Dense) (None, 1) 26
=================================================================
Total params: 27,851
Trainable params: 27,851
Non-trainable params: 0
_________________________________________________________________
None

最佳答案

这具有预期的形状

import numpy as np
a=np.array([[0.347669, 0.048266, 0.515875, -0.166667, 0.000000, 0.378772]])
print(a.shape) #(6,)

b=model.predict(a)
print(b)

关于python - Keras - 如何根据一个实例进行预测?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59885079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com