首页 > 解决方案 > 如何在 Windows 上的 R 中加载 Keras 模型?

问题描述

我很难在 R 中加载 keras 模型(.h5)。这是我尝试过的脚本:

library(keras)
new_model <- load_model_hdf5("model1.h5")

错误信息是:

Error in load_model_hdf5("model1.h5") : 
  The h5py Python package is required to save and load models

我还尝试以不同的格式保存模型(保存整个模型),但得到了不同的错误消息。这是我尝试过的:

new_model <- load_model_tf('model1')

错误信息是:

Error in if (tensorflow::tf_version() < "2.0.0") stop("TensorFlow version >= 2.0.0 is requires to load models in the SavedModel format.",  : 
  argument is of length zero

标签: rtensorflowkerash5py

解决方案


推荐阅读