0

当我尝试在模型上拟合训练集时,出现以下错误:

Error in py_call_impl(callable, dots$args, dots$keywords) : Evaluation error: Required version of NumPy not available: installation of Numpy
>= 1.6 not found.

我尝试导入 numpy 模块,但仍然出现错误:

library(reticulate)
np <- import('numpy')

这是代码:

nn_model = keras_model_sequential()
enter cnn_model %>% layer_dense(units = 20, activation = 'relu', kernel_initializer = 
                       initializer_random_uniform(minval = -0.05, maxval = 0.05, seed = 1), input_shape = ncol(xTrain)
                     ) %>%
         layer_dense(units = 5, activation = 'softmax', kernel_initializer = initializer_random_uniform(minval = -0.05,
                                                                                                        maxval = 0.05,
                                                                                                        seed = 1))
nn_model %>% compile(loss = 'categorical_crossentropy', optimizer = optimizer_sgd(lr = 0.1),
                 metrics = c('categorical_accuracy'))
nn_model %>% fit(xTrain, yTrain, epochs = 100, batch_size = 256, validation_split = 0.5)
nn_model %>% evaluate(xTest, yTest)
4

1 回答 1

0

不幸的是,如果您的系统中不存在 Numpy,该np <- import('numpy')命令似乎不会产生任何错误;尝试以下从 R 安装它:

library(reticulate)
py_install("numpy")
np <- import('numpy')
于 2019-02-15T11:38:32.300 回答