Я пытаюсь построить нейронную сеть, используя kerasR
, но получаю python ошибку импорта.
library(keras)
NN_units = 5
NN_model <- keras_model_sequential() %>%
layer_dense(units = NN_units, activation = 'relu', input_shape = NN_units) %>%
layer_dense(units = 2, activation = 'softmax')
library(kerasR)
plot_model(NN_model, to_file = "plot/NN_architecture.png")
Ошибка:
> Error in py_call_impl(callable, dots$args, dots$keywords) :
> ImportError: Failed to import `pydot`. Please install `pydot`. For
> example with `pip install pydot`.
> 6. stop(structure(list(message = "ImportError: Failed to import `pydot`. Please install `pydot`. For example with `pip install
> pydot`.",
> call = py_call_impl(callable, dots$args, dots$keywords),
> cppstack = structure(list(file = "", line = -1L, stack = c("/usr/local/lib/R/site-library/reticulate/libs/reticulate.so(Rcpp::exception::exception(char const*, bool)+0x7a) [0x7fc490fe1aba]",
> "/usr/local/lib/R/site-library/reticulate/libs/reticulate.so(Rcpp::stop(std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> > const&)+0x27)
> [0x7fc490fe1c17]", ...
> 5.
> _check_pydot at vis_utils.py#22
> 4. model_to_dot at vis_utils.py#79
> 3. plot_model at vis_utils.py#240
> 2. modules$keras.utils$plot_model(model = model, to_file = to_file,
> show_shapes = show_shapes, show_layer_names = show_layer_names)
> 1. plot_model(NN_model, to_file = "plot/NN_architecture.png")
Я попытался запустить :
!pip install pydot
от терминала. conda install pydot
и conda install pydotplus
py_install("pydot")
Который устанавливает пакет, но когда я пытаюсь запустить plot_model(NN_model, to_file = "plot/NN_architecture.png")
снова, я получаю ту же ошибку.
> py_config()
python: /home/USER/.local/share/r-miniconda/envs/r-reticulate/bin/python
libpython: /home/USER/.local/share/r-miniconda/envs/r-reticulate/lib/libpython3.6m.so
pythonhome: /home/USER/.local/share/r-miniconda/envs/r-reticulate:/home/msmith/.local/share/r-miniconda/envs/r-reticulate
version: 3.6.10 |Anaconda, Inc.| (default, Jan 7 2020, 21:14:29) [GCC 7.3.0]
numpy: /home/USER/.local/lib/python3.6/site-packages/numpy
numpy_version: 1.18.1