MCPcopy Create free account
hub / github.com/Tencent/NeuralNLP-NeuralClassifier / get_lr

Method get_lr

model/optimizer.py:106–120  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

104 super(BertAdam, self).__init__(params, defaults)
105
106 def get_lr(self):
107 lr = []
108 for group in self.param_groups:
109 for p in group['params']:
110 state = self.state[p]
111 if len(state) == 0:
112 return [0]
113 if group['t_total'] != -1:
114 schedule_fct = SCHEDULES[group['schedule']]
115 lr_scheduled = group['lr'] * schedule_fct(
116 state['step'] / group['t_total'], group['warmup'])
117 else:
118 lr_scheduled = group['lr']
119 lr.append(lr_scheduled)
120 return lr
121
122 def step(self, closure=None):
123 """Performs a single optimization step.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected