- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用学习的 .h5 文件进行预测。学习模型如下。
model =Sequential()
model.add(Dense(12, input_dim=3, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(4, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])
我将输入的形式写如下。
x = np.array([[band1_input[input_cols_loop][input_rows_loop]],[band2_input[input_cols_loop][input_rows_loop]],[band3_input[input_cols_loop][input_rows_loop]]])
prediction_prob = model.predict(x)
我认为形状是正确的,但出现了以下错误。
ValueError: Error when checking : expected dense_1_input to have shape (3,) but got array with shape (1,)
x
的形状显然是(3,1)
,但是上面的错误并没有消失(数据来自csv文件,格式为(值1,值2,值3,类)
)。
如何解决这个问题?
最佳答案
The shape of x is obviously
(3,1)
, but the above error continues.
你是对的,但这不是 keras 所期望的。它需要 (1, 3)
形状:按照惯例,轴 0 表示批量大小,轴 1 表示特征。第一个Dense
层接受3个特征,这就是为什么它在只看到一个特征时会提示。
解决方案很简单,就是转置x
。
关于python - ValueError : Error when checking : expected dense_1_input to have shape (3, )但得到形状为(1,)的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50336110/
我使用 Angular 2 CLI 创建了一个 Angular 2 项目并使用了 ng build --prod 命令并且没有出现任何错误。 当我将 dist 文件夹上传到我的网站时,应用程序加载时出
这是我正在尝试的代码:http://jsfiddle.net/sbrsK/10/ 在jsfiddle中运行正常,没有报错 尝试通过本地网络服务器在我的计算机上运行相同的程序是行不通的。正在加载以下文件
我是一名优秀的程序员,十分优秀!