tf2.0训练网络,使用官方预训练模型和权重时,在保存模型和参数时,出现这个错误:
代码:
model.save('model36_5.h5')
model.save_weights('weight_tf_model36_5.h5')
报错信息
NotImplementedError: Saving the model to HDF5 format requires the
model to be a Functional model or a Sequential model. It does not
work for subclassed models, because such models are defined via
the body of a Python method, which isn't safely serializable. Consider
saving to the Tensorflow Saved Model format (by setting
save_format="tf") or using `save_weights`.

错误原因:
自定义模型只保存参数(model_weight模型),官方模型保存参数和权重(.h5模型)
修改为:
model.s

在尝试使用TF2.0保存预训练模型时遇到NotImplementedError,因为自定义模型仅保存参数,而官方模型保存参数和权重。解决方法是将保存格式改为仅保存权重。
最低0.47元/天 解锁文章
1651

被折叠的 条评论
为什么被折叠?



