MCPcopy Create free account
hub / github.com/DragonisCV/RAM / update_learning_rate

Method update_learning_rate

ram/models/base_model.py:185–206  ·  view source on GitHub ↗

Update learning rate. Args: current_iter (int): Current iteration. warmup_iter (int): Warm-up iter numbers. -1 for no warm-up. Default: -1.

(self, current_iter, warmup_iter=-1)

Source from the content-addressed store, hash-verified

183 return init_lr_groups_l
184
185 def update_learning_rate(self, current_iter, warmup_iter=-1):
186 """Update learning rate.
187
188 Args:
189 current_iter (int): Current iteration.
190 warmup_iter (int): Warm-up iter numbers. -1 for no warm-up.
191 Default: -1.
192 """
193 if current_iter > 1:
194 for scheduler in self.schedulers:
195 scheduler.step()
196 # set up warm-up learning rate
197 if current_iter < warmup_iter:
198 # get initial lr for each group
199 init_lr_g_l = self._get_init_lr()
200 # modify warming-up learning rates
201 # currently only support linearly warm up
202 warm_up_lr_l = []
203 for init_lr_g in init_lr_g_l:
204 warm_up_lr_l.append([v / warmup_iter * current_iter for v in init_lr_g])
205 # set learning rate
206 self._set_lr(warm_up_lr_l)
207
208 def get_current_learning_rate(self):
209 return [param_group['lr'] for param_group in self.optimizers[0].param_groups]

Callers 1

train_pipelineFunction · 0.80

Calls 2

_get_init_lrMethod · 0.95
_set_lrMethod · 0.95

Tested by

no test coverage detected