paddle如何保存模型状态字典
收藏
paddle应该如何保存状态字典,使用paddle.save(ckpt,path)会报错
代码:
def ckpt_save(val_dict, model, optimizer, save_path):
ckpt = {
'acc': val_dict['acc_now'],
'loss': val_dict['loss_now'],
'epoch': val_dict['epoch_now'],
'model_state_dict': model.state_dict(),
'optimizer_state_dict': optimizer.state_dict(),
}
paddle.save(ckpt, save_path)
File "E:\0_Python\02_git\segmentation_paddle\my_utils\net_prepare.py", line 455, in model_save
ckpt_save(val_dict, model, optimizer, Model_ckpt_path)
File "E:\0_Python\02_git\segmentation_paddle\my_utils\net_prepare.py", line 469, in ckpt_save
paddle.save(ckpt, save_path)
File "C:\Users\12458\AppData\Local\Programs\Python\Python36\lib\site-packages\paddle\framework\io.py", line 289, in save
pickle.dump(saved_obj, f, protocol=pickle_protocol)
TypeError: can't pickle ParamBase objects
0
收藏
请登录后评论