dynamic learning rate
(self, global_step)
| 259 | self.use_cosine = use_cosine |
| 260 | |
| 261 | def construct(self, global_step): |
| 262 | """dynamic learning rate""" |
| 263 | if not self.use_cosine: |
| 264 | decay_lr = self.decay_lr(global_step) |
| 265 | else: |
| 266 | decay_lr = self.cosine_decay_lr(global_step) |
| 267 | if self.warmup_flag: |
| 268 | is_warmup = self.cast(self.greater(self.warmup_steps, global_step), |
| 269 | mstype.float32) |
| 270 | warmup_lr = self.warmup_lr(global_step) |
| 271 | lr = (self.one - is_warmup) * decay_lr + is_warmup * warmup_lr |
| 272 | else: |
| 273 | lr = decay_lr |
| 274 | # self.print(f"Learning rate: {lr.asnumpy().tolist()}") |
| 275 | return lr |
| 276 | |
| 277 | |
| 278 | def add_inference_params(opt): |
nothing calls this directly
no outgoing calls
no test coverage detected