本文介绍了R中的错误:必须使用h5py Python软件包才能保存和加载模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用R 3.4.2.我正在按照decryptr

I am using R 3.4.2. I am following example from decryptr package

library(decryptr)

# Download captchas
captcha <- download_tjmg(dest = 'img')
keras_tjmg <- decryptrModels::read_model('tjmg')

最后一行代码会产生错误

Last line of code produce an error

Error in keras::load_model_hdf5(file_path) :
  The h5py Python package is required to save and load models

我试图从终端重新安装h5py软件包.我还安装了keras软件包.我可以在pyrthon中导入h5py程序包,但是Rstudio无法以某种方式识别它.

I have tried to reinstall h5py package from terminal. I have also installed keras package. I can import h5py package in pyrthon, but Rstudio doesn't recognize it somehow.

推荐答案

我以前从未安装过这些软件包,但是我按以下步骤进行操作并成功!也花了一些时间,因为除了您报告的内容外,它还给我带来了许多错误.

I've never installed these packages before, but I proceeded as follows and succeeded! It took a bit of time, too, because it gave me a variety of errors besides what you reported.

最后,我想出了这个:在终端中,

Finally, I came up with this: in terminal,

pip uninstall h5py
pip install h5py
pip uninstall keras
pip install keras

我在Python中检查import h5py是否运行正确(第一次,它给我DLL失败.)然后在R中,重启后,

I checked in Python that import h5py runs true (the first time, it gave me a DLL failure.) Then in R, after restarting,

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

让我知道是否可以解决.

Let me know if this works out.

这篇关于R中的错误:必须使用h5py Python软件包才能保存和加载模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-29 14:28