如何将 .pb 文件转换为 .h5。(张量流模型到keras)

Vam*_*avi 6 python keras tensorflow

我已经使用重新训练了我的模型tensorflow,现在想使用它keras来避免会话内容。我怎样才能将.pb文件转换为.h5

niv*_*led 4

import tensorflow as tf
from tensorflow.keras.models import save_model, Sequential

model_path = r"c:\temp\model.pb"

model = tf.keras.models.load_model(model_path)

save_model(model,model_path + r"\new_model.h5", save_format='h5')
Run Code Online (Sandbox Code Playgroud)