0

When I try to fit the training sets on the model, I get the following error:

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.

I tried to import the numpy module but I still get the error:

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

This is the code:

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)
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Mara
  • 17
  • 4
  • You need to install Numpy, which is a *Python* package and cannot be installed by R's `install.packages`. – desertnaut Feb 15 '19 at 10:24
  • Any luck with the answer? – desertnaut Feb 15 '19 at 14:59
  • not really, after I tried it, I got another errors. It was an issue with the keras library, and having multiple virtual environments where modules of python were installed. I solved the numpy module issue but then it tells me it cannot find keras module... – Mara Feb 18 '19 at 06:32

1 Answers1

0

Unfortunately, it seems that the np <- import('numpy') command will not produce any error if Numpy is not present in your system; try the following to install it from R:

library(reticulate)
py_install("numpy")
np <- import('numpy')
desertnaut
  • 57,590
  • 26
  • 140
  • 166