这是我第一次使用 keras,我正在尝试按照我在网上找到的教程并将我自己的数据适合它。我有一个矩阵和二进制标签。
> str(d_train)
num [1:1062, 1:180] -0.04748 0.04607 -0.05429 -0.0126 -0.00219 ...
> str(trainlabels)
num [1:1062, 1:2] 0 0 0 0 0 0 1 0 0 0 ...
Run Code Online (Sandbox Code Playgroud)
我的代码:
model = keras_model_sequential()
model %>%
layer_dense(units = 8, activation = 'relu', input_shape = c(180)) %>%
layer_dense(units = 3, activation = "softmax")
summary(model)
## Compile
model %>%
compile(loss = "binary_crossentropy",
optimizer = "adam",
metrics = "accuracy")
## Fit model
history = model %>%
fit(d_train,
trainlabels,
epoch=200,
batch_size=32,
validation_split=0.2)
Run Code Online (Sandbox Code Playgroud)
我似乎不适合模型,我收到此错误消息:
Error in …
Run Code Online (Sandbox Code Playgroud) 我在 Windows 中看到了这个问题的答案,但没有看到任何适用于 Mac 的解决方案。
安装 keras 后,如:
devtools::install_github("rstudio/keras")
library(keras)
install_keras()
Run Code Online (Sandbox Code Playgroud)
运行时出现错误:
library(keras)
mnist <- dataset_mnist()
>> Error in initialize_python(required_module, use_environment) :
Python shared library not found, Python bindings not loaded.
Run Code Online (Sandbox Code Playgroud)
我尝试了以下方法:
use_python("/Users/me/anaconda3/bin/python3.7", required = TRUE)
use_virtualenv("~/MyFolder/.venv/")
use_python("~/MyFolder/.venv/bin/python")
Run Code Online (Sandbox Code Playgroud)
但是没有成功,我看到了一些关于错误安装 python 的建议,但在我的情况下不应该是这样。我已经用 Anaconda 安装了 python 3.7.5
=> python --version
Python 3.7.5
Run Code Online (Sandbox Code Playgroud)
我在 RStudio 中使用 macOS Catalina 版本 10.15.1,版本 1.2.5019。有没有人有任何解决方案?