根据以下情况,我想在AdamW optimizer
中使用keras
进行NN
培训:
https://github.com/GLambard/AdamW_Keras
我导入了该代码,该代码似乎可以像宣传的那样工作。不幸的是,当我加载一个保存的检查点时,出现错误:
file "ResUNET.py", line 209, in <module>
'peteLoss': mc.peteLoss, 'iou_one_Metric': mc.iou_one_Metric, 'adamw': adamw})
File "/home/pete/anaconda3/lib/python3.6/site-packages/keras/engine/saving.py", line 276, in load_model
custom_objects=custom_objects)
File "/home/pete/anaconda3/lib/python3.6/site-packages/keras/optimizers.py", line 760, in deserialize
printable_module_name='optimizer')
File "/home/pete/anaconda3/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 138, in deserialize_keras_object
': ' + class_name)
ValueError: Unknown optimizer: AdamW
我确实根据以下条件传递了自定义对象:
model = load_model(save_model_name,custom_objects={
'my_iou_metric': mc.my_iou_metric,
'my_iou_metric_2': mc.my_iou_metric_2,
'lovasz_loss': mc.lovasz_loss,
'peteLoss': mc.peteLoss,
'iou_one_Metric': mc.iou_one_Metric,
'adamw': adamw})
这对损失等有效,但对优化器却无效。