且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

加载模型Raise ValueError未知损失函数

更新时间:2023-12-02 19:11:34

TL/DR:当保存的模型中有custom_objects时,则需要提供compile = False作为load_model的参数.加载模型后,需要使用custom_objects进行编译.请在此处查看示例.

TL/DR: When you have custom_objects in the saved model, then you need to provide compile = False as an argument to the load_model. After loading the model, you need to compile with the custom_objects. Please check the example here.

在保存带有custom_objects的模型时,这些custom_objects无法正确序列化.因此,在加载模型时,您需要传递compile=False并加载模型.加载模型后,您需要通过传递自定义对象来编译模型.

When you save a model with custom_objects, those custom_objects cannot be serialized properly. So, when you load the model you need to pass compile=False and load the model. After loading the model, you need to compile the model by passing the custom objects.