keras - py_call_impl(callable, dots\$args, dots\$keywords) 中的错误 - 与 Leprechault 类似的情况,但
问题描述
我面临一个几个小时都无法解决的问题……我想我需要一些帮助。我从R 示例中的示例 Keras开始,该示例在我的环境中运行良好
然后我使用下面的基本脚本,调用 fit() 函数时总是失败,我无法找出问题所在。我检查了类,我的输入数据的暗淡,这听起来不错...我尝试在调用 fit() 之前执行 as.array() 转换,但这给出了相同的结果。
df<-read.csv("https://raw.githubusercontent.com/stchln/test/main/prtt.csv",sep=",")
xn<-cbind(df$L1SW,df$L2SW,df$L3SW,df$BOAMSW,df$RFSW,df$ET,df$ST)
yn<-cbind(df$pronto_id)
library(keras)
model = keras_model_sequential() %>%
layer_dense(units=64, activation="relu", input_shape=3) %>%
layer_dense(units=32, activation = "relu") %>%
layer_dense(units=1, activation="linear")
model %>% compile(
loss = "mse",
optimizer = "adam",
metrics = list("mean_absolute_error")
)
model %>% summary()
model %>% fit(xn, yn, epochs = 100,verbose = 0)
我 在 py_call_impl(callable, dots\$args, dots\$keywords) 中得到错误: ValueError: 在用户代码中:
任何想法?
解决方案
当您的数据维度不正确/与模型架构不匹配时,通常会发生此错误,另请参阅此 github 问题。在您的情况下,这可能是由于您传入 7 列但将其设置input_shape
为 3。尝试将input_shape
参数的值更改为 7:
model = keras_model_sequential() %>%
layer_dense(units=64, activation="relu", input_shape=7) %>%
layer_dense(units=32, activation = "relu") %>%
layer_dense(units=1, activation="linear")
推荐阅读
- javascript - HTML脚本标签内的JavaScript代码不起作用
- websphere - 如何在 IBM HTTP Server 上启用 SSLv3?
- xquery - 如何检查我的 cts:and-query 或 cts:or-query 是否包含任何元素查询
- python - 为什么这个队列在多处理中不起作用?(函数体中的 append() 方法)
- javascript - 无法从 Node.js 修改 HTML 元素的值
- autodesk-forge - 关于锻造的第一人称
- javascript - 反应原生时刻格式的日期无效
- django - 反序列化与属性名称不同的字段名称
- ios - AppStore 为我的 ios 应用程序拒绝此消息的原因是什么?
- c# - 在 Visual Studio 中组织 EF 配置类的最佳实践