使用Lambda層加入自定義的函數(shù)后槽片,訓(xùn)練沒有出錯灯抛,但是在載入保存的模型時顯示錯誤妇押。
1."AttributeError: 'NoneType' object has no attribute 'get'"
解決方法:這個問題是由于缺少config信息導(dǎo)致的需了。Lambda層在載入時需要載入一個函數(shù)跳昼,當(dāng)使用自定義函數(shù)時,模型無法找到則個函數(shù)肋乍,也就構(gòu)建不了模型鹅颊。
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})