deepfacelab中文网

 找回密码
 立即注册(仅限QQ邮箱)
查看: 23|回复: 0

我看到关于优化器和lrd的文档

[复制链接]

41

主题

259

帖子

2038

积分

初级丹圣

Rank: 8Rank: 8

积分
2038
 楼主| 发表于 6 小时前 | 显示全部楼层 |阅读模式
星级打分
  • 1
  • 2
  • 3
  • 4
  • 5
平均分:NAN  参与人数:0  我的评分:未评
36. Q: How to train with AdaBelief enabled?

A: Same as you would do without it enabled except without using learning rate dropout which is not needed with AB enabled.

Whether you're starting to pretrain a new model, starting training on a pretrained model or want to carry on training with old model but use AdaBelief to improve quality of your fakes enable it and remember to never turn it off once it's enabled.

Don't use LRD, this option should disable itself but just to be sure run your model once, disable LRD, save and then start it again, select Y to enable AdaBelief optimizer and pretrain or train as usual.

There is no need to enable LRD before GAN, once you've disabled RW and are ready to start GAN simply enable it, no need to run LRD and wait for the model to reach lower loss, AB will ensure the model trains more accurately and naturally reaches lower loss values.

If it's a pretrained model or one that was heavily trained before and you want to use it with AB make sure to enable it and RW, let the model relearn everything, if you instead just enable AB and carry on with RW disabled or some other options enabled it may not improve or it will get worse.

这个文档是哪里来的?

我分析了遍

AdaBelief 是默认开启的

default_adabelief = self.options['adabelief'] = self.load_or_def_option('adabelief', True)
新版 DFL 中 adabelief 默认为 True。这意味着你新建模型时默认就是 AdaBelief,问答中说的 "select Y to enable AdaBelief" 对应的就是第 150 行的交互询问。



"without using learning rate dropout which is not needed with AB enabled"
源码验证:代码中 AdaBelief 和 RMSprop 都接受lr_dropout参数,并没有自动互斥。但从算法原理看:
AdaBelief 的 (g - m_t)² 已经对每个参数做了自适应步长归一化-------梯度稳定的参数自动获得大步长,梯度波动的参数自动获得小步长
LRD 通过随机置零 70% 参数的更新来制造稀疏性,本质是一种正则化 + 锐化手段
AdaBelief 的自适应特性已经部分覆盖了 LRD 的 "精细调节" 作用,两者叠加反而可能导致更新过于稀疏、收敛变慢
"never turn it off once it's enabled"
源码层面的根本原因 ------优化器状态文件不兼容:
AdaBelief 的 src_dst_opt.npy 保存:iterations + ms_dict(m_t) + vs_dict(v_t)
RMSprop 的 src_dst_opt.npy 保存:iterations + accumulators_dict(a)
他的加载逻辑中,如果从 AdaBelief 切回 RMSprop,RMSprop 找不到对应的 accumulator 变量,load_weights()会失败-----触发init_weights()---优化器状态从零开始
动量从零开始意味着模型失去了之前累积的梯度方向信息,训练会出现明显的质量回退
"this option should disable itself but just to be sure run your model once, disable LRD, save and then start it again"
源码验证:当前版本并没有自动禁用 LRD的逻辑。问答中的 "should disable itself" 更像是一种经验性建议或旧版本行为。安全做法确实是手动确认:
启动训练--------进入选项询问→将 LRD 设为'n'
保存配置后退出
重新启动,确认 LRD 为'n'后再开始训练
"There is no need to enable LRD before GAN"


源码中的传统训练顺序

LRD(enable) -----random_warp(disable) ----- GAN(enable)

这是 RMSprop 时代的标准流程:先用 LRD 提升锐度-----关 RW 进一步锐化------最后开 GAN 学细节。
用 AdaBelief 时可以直接跳过 LRD 阶段,流程简化为:

random_warp(训练到足够)----- disable RW- ---enable GAN


因为 AdaBelief 本身就能让模型 "更准确、自然地达到更低 loss"(问答原文)。
"If it's a pretrained model... make sure to enable it and RW, let the model relearn everything"
源码层面的原因:
优化器状态重置:从 RMSprop 切换到 AdaBelief 时,ms_dict和vs_dict都是全新初始化的零值,相当于优化器 "失忆"
random_warp 的作用,源码中明确说明:"Random warp is required to generalize facial expressions"---- 在数据增强下重新训练,让模型在更丰富的样本分布中重新适应 AdaBelief 的更新动态
如果 RW 关闭直接切:模型在固定的、无扭曲的样本分布上用一个 "失忆" 的优化器微调,AdaBelief 的二阶动量需要数千次迭代才能积累到有意义的值,这段时间内模型可能出现不稳定或质量下降



总结:源码层面的操作建议

全新训练        adabelief=True, lr_dropout='n'        默认就是这样,直接训练即可
从 RMSprop 旧模型切换        开启 AdaBelief + 保持 RW=True        优化器状态会重置,需要重新 warm up
预训练        代码自动强制 LRD='n', RW=False, GAN=0        预训练结束后切回正常训练时 iter 会归零
开启 GAN        确保 LRD='n', RW=False        GAN 判别器也用同一个优化器类


关键:AdaBelief 不需要 LRD!直接 warp(✓→✗) → GAN,无需中间 LRD 阶段

RMSprop  

关键:必须先 LRD(y) → 再 warp(✗) → 最后 GAN,三步不能跳过

总结:这个文档应该是旧的RMSprop 时代的标准流程吧,谁有完整的文档,发下我看看。


回复

使用道具 举报

QQ|Archiver|手机版|deepfacelab中文网 |网站地图

GMT+8, 2026-8-25 07:18 , Processed in 0.082562 second(s), 28 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表