accum专题

args.grad_accum_steps = max(1, args.grad_accum_steps)

# 将args.grad_accum_steps的值与1比较取较大值,确保args.grad_accum_steps至少为1。这个设置通常用于控制梯度累积的步数。 args.grad_accum_steps = max(1, args.grad_accum_steps) 梯度累积 why? 模型太大,不能一次性装入显存 What? 将多个小批次的的梯度累积起来,一次性参数更新 how