mindpores 加载checkpoint的时候报warning日志 "xxx parameters in the net are not

1. 系统环境:

Hardware Environment(Ascend/GPU/CPU): ALL
Software Environment:
MindSpore version (source or binary): 1.7.0 & Earlier versions
Python version (e.g., Python 3.7.5): 3.7.6
OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu
GCC/Compiler version (if compiled from source):

2. python代码样例

net = Net()
load_checkpoint("net.ckpt", net=net)

3. 报错信息:

Warnning: [mindspore/train/serialization.py]  xxx parameters in the 'net' are not loaded, because they are not in the 'parameter_dict'

4. 原因分析

报错信息为:把checkpoint文件中的参数加载到网络中时,发现网络中的一些参数没有被加载上。

具体原因为,checkpoint文件中没有那些参数,导致加载时找不到对应的参数。

5. 解决方法

产生这种告警的情况大部分是,训练和加载checkpoint时的网络结构不一致导致的。 首先排查网络定义,是否一致,其次排查是否有超参导致两者内部结构发生变化。 如无结果,可以使用network.parameters_dict方法获取网络中的参数; 使用param_dict = load_checkpoint("net.ckpt")方法获取checkpoint中的参数字典,再对比二者的差异。

6. 参考文档

checkpoint 用法可以参考: 保存与加载

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值