MCPcopy
hub / github.com/open-mmlab/OpenPCDet / step

Method step

tools/train_utils/optimization/fastai_optim.py:135–152  ·  view source on GitHub ↗

Set weight decay and step optimizer.

(self)

Source from the content-addressed store, hash-verified

133
134 # Pytorch optimizer methods
135 def step(self) -> None:
136 "Set weight decay and step optimizer."
137 # weight decay outside of optimizer step (AdamW)
138 if self.true_wd:
139 for lr, wd, pg1, pg2 in zip(self._lr, self._wd, self.opt.param_groups[::2], self.opt.param_groups[1::2]):
140 for p in pg1['params']:
141 # When some parameters are fixed: Shaoshuai Shi
142 if p.requires_grad is False:
143 continue
144 p.data.mul_(1 - wd * lr)
145 if self.bn_wd:
146 for p in pg2['params']:
147 # When some parameters are fixed: Shaoshuai Shi
148 if p.requires_grad is False:
149 continue
150 p.data.mul_(1 - wd * lr)
151 self.set_val('weight_decay', listify(0, self._wd))
152 self.opt.step()
153
154 def zero_grad(self) -> None:
155 "Clear optimizer gradients."

Callers 2

train_one_epochFunction · 0.45
stepMethod · 0.45

Calls 2

set_valMethod · 0.95
listifyFunction · 0.85

Tested by

no test coverage detected