R中的错误:需要h5py Python包来保存和加载模型
问题描述:
我正在使用R 3.4.2。我下面从decryptr
packageR中的错误:需要h5py Python包来保存和加载模型
library(decryptr)
# Download captchas
captcha <- download_tjmg(dest = 'img')
keras_tjmg <- decryptrModels::read_model('tjmg')
最后的代码行例如产生一个错误
Error in keras::load_model_hdf5(file_path) :
The h5py Python package is required to save and load models
我试图从终端重新安装h5py包。我也安装了keras
包。我可以在pyrthon中导入h5py软件包,但Rstudio无法以某种方式识别它。
答
我以前从未安装过这些软件包,但是我按照以下步骤继续操作并成功完成!这也花了一点时间,因为除了你所报告的内容之外,它给了我各种各样的错误。
最后,我想出了这一点:在终端,
pip uninstall h5py
pip install h5py
pip uninstall keras
pip install keras
我在Python检查了import h5py
运行真(。第一次,它给了我一个DLL失败)然后R,重新启动后,
install.packages("reticulate")
install.packages("tensorflow")
install.packages("keras")
install.packages("h5py")
devtools::install_github("decryptr/decryptr")
devtools::install_github("decryptr/decryptrModels")
library(keras)
install_keras()
# Check where Python's looked for
reticulate::py_config()
library(decryptr)
library(decryptrModels)
captcha <- captcha_download_tjmg(dest = 'img')
keras_tjmg <- read_model('tjmg')
我sessionInfo()
如下:
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] decryptrModels_0.0.0.9000 decryptr_0.0.1.9000
[3] keras_2.0.8.9001
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 prettyunits_1.0.2 assertthat_0.2.0
[4] R6_2.2.2 jsonlite_1.5 magrittr_1.5
[7] httr_1.3.1 tfruns_1.0 rlang_0.1.2
[10] progress_1.1.2 curl_2.8.1 whisker_0.3-2
[13] reticulate_1.2.0.9005 tools_3.4.1 purrr_0.2.3
[16] compiler_3.4.1 base64enc_0.1-3 tensorflow_1.4.0.9003
让我KN如果这个解决的话。
你使用anaconda?我有这个问题一次,我通过安装h5py(r-tensorflow)环境中的pip解决。 – Athos