keras load model 遇到 自定义函数 Lambda(lambda x: softmax(x, axis=1), NameError: global name 'softmax' is not defined

问题

在定义模型的时候,自定义了一个函数

模型保存之后,load 模型的时候报错:

解决

load 模型的时候需要指定custom object

参考:
https://faroit.github.io/keras-docs/2.1.5/getting-started/faq/#handling-custom-layers-or-other-custom-objects-in-saved-models

猜你喜欢

转载自www.cnblogs.com/zle1992/p/9083479.html