在AWS Sagemaker中加载keras json模型时出错

时间:2020-06-28 11:16:03

标签: json python-3.x tensorflow keras

我正在尝试从json加载keras模型,但出现错误

ValueError: Tensor-typed variable initializers must either be wrapped in an init_scope or callable (e.g., `tf.Variable(lambda : tf.truncated_normal([10, 40]))`) when building functions.

下面是我尝试过的代码

import tensorflow as tf
from keras.models import model_from_json
json_file = open('/home/ec2-user/SageMaker/keras_model/'+'mpg_model.json', 'r')
loaded_model_json = json_file.read()
json_file.close()
loaded_model = model_from_json(loaded_model_json,custom_objects={"GlorotUniform": tf.keras.initializers.glorot_uniform})

0 个答案:

没有答案