美文网首页
Keras中加入Lambda层无法正常载入模型问题

Keras中加入Lambda层无法正常载入模型问题

作者: 缸里有绿粥 | 来源:发表于2020-05-19 14:40 被阅读0次

使用Lambda层加入自定义的函数后,训练没有出错,但是在载入保存的模型时显示错误。

1."AttributeError: 'NoneType' object has no attribute 'get'"

解决方法:这个问题是由于缺少config信息导致的。Lambda层在载入时需要载入一个函数,当使用自定义函数时,模型无法找到则个函数,也就构建不了模型。

load_model(path, custom_objects={"batch_d":self.batch_d, "trans":self.trans})

2."name: 'tf' is not defined"

解决方法:在config信息里面加一条 custom_objects={'tf': tf}

load_model(path, custom_objects={"batch_d":self.batch_d, "trans":self.trans, 'tf': tf})

相关文章

网友评论

      本文标题:Keras中加入Lambda层无法正常载入模型问题

      本文链接:https://www.haomeiwen.com/subject/hsrbohtx.html