error: python module tensorflow.keras was not found. detected python configuration

error: python module tensorflow.keras was not found.  detected python configuration

目录

error: python module tensorflow.keras was not found.  detected python configuration

问题:

解决:

完整错误:


问题:

原来的安装有问题,程序如法运行;

原来的安装方式为:

install.packages('keras')

install.packages('tensorflow')

删除已经安装的keras和tensorflow包。

remove.packages('package_name')

library(DAAG)

head(ais)

# standardise
minmax <- function(x) (x - min(x))/(max(x) - min(x))
x_train <- apply(ais[,1:11], 2, minmax)


library(keras)

# set training data
x_train <- as.matrix(x_train)
# set model
model <- keras_model_sequential()
model %>%
  layer_dense(units = 6, activation = "tanh", input_shape = ncol(x_train)) %>%
  layer_dense(units = 2, activation = "tanh", name = "bottleneck") %>%
  layer_dense(units = 6, activation = "tanh") %>%
  layer_dense(units = ncol(x_train))
# view model layers
summary(model)

解决:

安装tensorflow和keras

  • devtools::install_github("rstudio/tensorflow")
  • devtools::install_github("rstudio/keras")

接着执行如下程序:

  • tensorflow::install_tensorflow()
  • tensorflow::tf_config()

接着在library(keras)的时候又发生错误:

需要从windows的指定地址下载匹配的文件处理;

Latest supported Visual C++ Redistributable downloads | Microsoft Learn

library(DAAG)

head(ais)

# standardise
minmax <- function(x) (x - min(x))/(max(x) - min(x))
x_train <- apply(ais[,1:11], 2, minmax)


library(keras)

# set training data
x_train <- as.matrix(x_train)
# set model
model <- keras_model_sequential()
model %>%
  layer_dense(units = 6, activation = "tanh", input_shape = ncol(x_train)) %>%
  layer_dense(units = 2, activation = "tanh", name = "bottleneck") %>%
  layer_dense(units = 6, activation = "tanh") %>%
  layer_dense(units = ncol(x_train))
# view model layers
summary(model)

正确的输出:

> model <- keras_model_sequential()
2022-12-04 17:59:02.205597: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2022-12-04 17:59:02.205841: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-12-04 17:59:12.769104: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2022-12-04 17:59:12.769266: W tensorflow/stream_executor/cuda/cuda_driver.cc:263] failed call to cuInit: UNKNOWN ERROR (303)
2022-12-04 17:59:12.773317: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: XA311683
2022-12-04 17:59:12.773378: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: XA311683
2022-12-04 17:59:12.776187: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
> model %>%
+     layer_dense(units = 6, activation = "tanh", input_shape = ncol(x_train)) %>%
+     layer_dense(units = 2, activation = "tanh", name = "bottleneck") %>%
+     layer_dense(units = 6, activation = "tanh") %>%
+     layer_dense(units = ncol(x_train))
> # view model layers
> summary(model)
Model: "sequential"
_________________________________________________________________________________
 Layer (type)                       Output Shape                    Param #      
=================================================================================
 dense_2 (Dense)                    (None, 6)                       72           
 bottleneck (Dense)                 (None, 2)                       14           
 dense_1 (Dense)                    (None, 6)                       18           
 dense (Dense)                      (None, 11)                      77           
=================================================================================
Total params: 181
Trainable params: 181
Non-trainable params: 0
_________________________________________________________________________________

完整错误:

error: python module tensorflow.keras was not found. detected python configuration

参考:Keras @ Error: Python module tensorflow.keras was not found. - Posit Cloud - RStudio Community

参考:keras

参考:tensorflow

参考:R keras package Error: Python module tensorflow.contrib.keras.python.keras was not found - Stack Overflow

参考:tensorflow/README.md at master · rstudio/tensorflow · GitHub

参考:r - Siamese Network using Rstudio Keras - Stack Overflow

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Data+Science+Insight

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值