rstudio中用keras创建Sequential模型报错
分类:R
错误信息:ValueError: Only input tensors may be passed as positional arguments
出现这个错误有可能是keras
和keras3
冲突。
This happens if both keras
and keras3
are loaded. Until this is fixed with an updated release of keras
, please uninstall keras
to avoid accidentally loading it, and only use keras3
.
remove.packages("keras")
install.packages("keras3") # or remotes::install_github("rstudio/keras")
library(keras3)
也可能是tensorflow的版本问题:
you're using keras 2.15 and tensorflow 2.16, which may be causing a problem. I think you'll need tensorflow 2.15 to use the latest version of the keras package.
在你的虚拟环境中安装 tensorflow 2.15 试试:
pip install tensorflow==2.15