ry tensorflow在r中的virtualenv_install中的错误
我正在尝试使用Rstudio的Keras库来培训模型。
library(keras)
N <- 100
x <- runif(N, -2, 3)
# Build a Gompertz function with some noise
a <- 10 # ceiling parameter
b <- 0 # horizontal shift parameter
c <- 2 # growth rate parameter
y <- a*exp(-exp(b - c*x)) + rnorm(N, mean=0, sd= a/10)
plot(x,y)
# format data in a way model.fit() would like it
x <- as.matrix(x)
y <- as.matrix(y)
# sequence along x for later prediction
xnew <- as.matrix(seq(from=min(x), to=max(x), length.out=1000))
# Build and compile simple model
model <- keras_model_sequential() |>
layer_dense(units=32, activation="relu", input_shape=1) |>
layer_dense(units=16, activation = "relu") |>
layer_dense(units=1, activation="linear")
此时我有一个错误
错误:找不到Python模块Tensorflow.keras。 检测到的Python配置:
我发现了一个类似的问题在这里
library(keras)
library(tensorflow)
install_tensorflow()
install_keras()
我有一个错误:
virtualenv_install中的错误 ignore_installed = pip_ignore_installed,:'/usr/local/bin'存在 但不是虚拟环境
我在Python 3.9中安装了Tensorflow和Keras。这是我的pip3冻结输出:
I am trying to train a model using keras library in RStudio.
library(keras)
N <- 100
x <- runif(N, -2, 3)
# Build a Gompertz function with some noise
a <- 10 # ceiling parameter
b <- 0 # horizontal shift parameter
c <- 2 # growth rate parameter
y <- a*exp(-exp(b - c*x)) + rnorm(N, mean=0, sd= a/10)
plot(x,y)
# format data in a way model.fit() would like it
x <- as.matrix(x)
y <- as.matrix(y)
# sequence along x for later prediction
xnew <- as.matrix(seq(from=min(x), to=max(x), length.out=1000))
# Build and compile simple model
model <- keras_model_sequential() |>
layer_dense(units=32, activation="relu", input_shape=1) |>
layer_dense(units=16, activation = "relu") |>
layer_dense(units=1, activation="linear")
at this point I got an error
Error: Python module tensorflow.keras was not found. Detected Python configuration:
I found a similar issue here and tried to
library(keras)
library(tensorflow)
install_tensorflow()
install_keras()
But I got this error:
Error in virtualenv_install(envname = envname, packages = packages,
ignore_installed = pip_ignore_installed, : '/usr/local/bin' exists
but is not a virtual environment
I have tensorflow and keras installed in my python 3.9. Here is my pip3 freeze output:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过在A Fresh R Session 中运行以下操作来解决许多安装问题(您可以使用CTRL+Shift+F10重新启动RSTUDIO的R):
测试以查看安装是否成功。
如果以上片段成功,并且您看到了
tf.tensor(b'hello world',shape =(),dtype = string)
,那么您已经成功安装了TensorFlow!如果没有,请在
Many installation issues are resolved by running the following in a fresh R session (you can restart R in Rstudio with Ctrl+Shift+F10) :
Test to see if installation was successful.
If the above snippet succeeded and you saw something like
tf.Tensor(b'Hello World', shape=(), dtype=string)
, then you've successfully installed Tensorflow!If not, please file an issue at https://github.com/rstudio/tensorflow/issues