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