当前位置: 代码迷 >> 综合 >> Tensorflow2.0 保存模型时出现 NotImplementedError 的解决方法
  详细解决方案

Tensorflow2.0 保存模型时出现 NotImplementedError 的解决方法

热度:92   发布时间:2023-10-28 13:21:21.0

如果保存用类定义的模型,那么很有可能会出现以下错误:

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 SavedModel format (by setting save_format="tf") or using `save_weights`.

此时如果我们将此模型改为用函数定义,便不会再出现这个错误。

  相关解决方案