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

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
### 回答1: 你可以用 pip 安装 TensorFlowKeras:pip install tensorflow 和 pip install keras。如果你想要安装特定的 TensorFlow 版本,你可以使用 pip install tensorflow==<version>。 ### 回答2: tensorflow keras 是一种机器学习框架,在安装之前,我们首先需要安装好 Python 环境。接下来,我们可以通过以下步骤来安装 tensorflow keras: 1. 打开终端或命令行界面,并确保已经安装了 pip,pip 是 Python 包管理器,用于安装第三方软件包。 2. 在终端中输入以下命令来安装 tensorflow keras: `pip install tensorflow` 这会自动安装最新版本的 tensorflow 包。 3. 安装完成后,我们可以在 Python 中导入 tensorflow 包,并验证其安装是否成功: ```python import tensorflow as tf print(tf.__version__) ``` 这将输出 tensorflow 版本号,表示 tensorflow 安装成功。 4. 接下来,我们可以安装 keraskeras 是基于 tensorflow 的高级神经网络 API。在终端中输入以下命令安装 keras: `pip install keras` 这将自动安装最新版本的 keras。 5. 安装完成后,我们可以在 Python 中导入 keras,并验证其安装是否成功: ```python import keras print(keras.__version__) ``` 这将输出 keras 版本号,表示 keras 安装成功。 至此,我们已经成功安装了 tensorflow keras。现在,我们可以开始使用这个强大的机器学习框架来构建和训练深度学习模型了。 ### 回答3: 要安装TensorFlowKeras,你可以按照以下步骤进行操作: 1. 确保你的计算机已经安装好Python,并且Python版本在3.5以上。 2. 打开命令行界面,使用以下命令安装TensorFlow: ``` pip install tensorflow ``` 如果你的计算机上同时安装有GPU并且想要使用GPU加速,可以使用以下命令来安装TensorFlow GPU版本: ``` pip install tensorflow-gpu ``` 3. 安装完成后,使用以下命令来验证TensorFlow的安装情况: ``` python -c "import tensorflow as tf;print(tf.__version__)" ``` 如果成功安装,将会显示出TensorFlow的版本号。 4. 接下来,你可以安装Keras。使用以下命令来安装Keras: ``` pip install keras ``` 另外,Keras已经成为TensorFlow的一部分,如果你已经成功安装了TensorFlow,在导入TensorFlow时,也可以通过调用`tf.keras`来使用Keras。 至此,你已经成功安装了TensorFlowKeras。你可以通过导入相应库和模块来使用它们。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 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、付费专栏及课程。

余额充值