更新时间:2025-01-22 gmt 08:00
如何在modelarts训练作业中加载部分训练好的参数?-九游平台
在训练作业时,需要从预训练的模型中加载部分参数,初始化当前模型。请您通过如下方式加载:
- 通过如下代码,您可以查看所有的参数。
from moxing.tensorflow.utils.hyper_param_flags import mox_flags print(mox_flags.get_help())
- 通过如下方式控制载入模型时需要恢复的参数名。其中,“checkpoint_include_patterns”为需要恢复的参数,“checkpoint_exclude_patterns”为不需要恢复的参数。
checkpoint_include_patterns: variables names patterns to include when restoring checkpoint. such as: conv2d/weights. checkpoint_exclude_patterns: variables names patterns to include when restoring checkpoint. such as: conv2d/weights.
- 通过以下方式控制需要训练的参数列表。其中,“trainable_include_patterns”为需要训练的参数列表,“trainable_exclude_patterns”为不需要训练的参数列表。
--trainable_exclude_patterns: variables names patterns to exclude for trainable variables. such as: conv1,conv2. --trainable_include_patterns: variables names patterns to include for trainable variables. such as: logits.
父主题: standard模型训练
相关文档
意见反馈
文档内容是否对您有帮助?
提交成功!非常感谢您的反馈,我们会继续努力做到更好!
您可在查看反馈及问题处理状态。
系统繁忙,请稍后重试
如您有其它疑问,您也可以通过华为云社区问答频道来与我们联系探讨