Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问有尝试过将该模型保存为savedmodel格式的吗?我保存成这样后再读取就会出错 #4

Open
kill2013110 opened this issue Nov 3, 2021 · 4 comments

Comments

@kill2013110
Copy link

使用savedmodel是因为要后续准备冻结模型。
函数用的tf.keras.model.save_model()和tf.keras.model.load_model()
分析了一下,是因为模型中包含了自定义的Lambda层,所以报错了,
对于lambda层我准备转为tf.function, 应该可以解决问题,
您有什么好的建议吗

@bubbliiiing
Copy link
Owner

我没有试过其实…

@Duton
Copy link

Duton commented Apr 5, 2022

请问你解决这个问题了么?

@kill2013110
Copy link
Author

请问你解决这个问题了么?

解决了,因为把loss当做自定义的lambda层也放进网络里了,这样训练时网络的输出就是loss,比较简洁,你可以仔细看训练模型的代码,但这个lambda层是不支持savedmodel格式的。 解决办法:可以建一个不包括自定义loss层的模型,然后将训练好的weight load进去,再savedmodel保存

@bubbliiiing
Copy link
Owner

,可以在预测的时候……save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants