我正在尝试从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})