30
30
"""
31
31
32
32
33
- def float_global_step ():
33
+ def _decay_step_counter ():
34
34
# the first global step is zero in learning rate decay
35
35
global_step = layers .autoincreased_step_counter (
36
36
counter_name = '@LR_DECAY_COUNTER@' , begin = 0 , step = 1 )
@@ -55,7 +55,7 @@ def exponential_decay(learning_rate, decay_steps, decay_rate, staircase=False):
55
55
Returns:
56
56
The decayed learning rate
57
57
"""
58
- global_step = float_global_step ()
58
+ global_step = _decay_step_counter ()
59
59
60
60
with init_on_cpu ():
61
61
# update learning_rate
@@ -85,7 +85,7 @@ def natural_exp_decay(learning_rate, decay_steps, decay_rate, staircase=False):
85
85
Returns:
86
86
The decayed learning rate
87
87
"""
88
- global_step = float_global_step ()
88
+ global_step = _decay_step_counter ()
89
89
90
90
with init_on_cpu ():
91
91
div_res = global_step / decay_steps
@@ -114,7 +114,7 @@ def inverse_time_decay(learning_rate, decay_steps, decay_rate, staircase=False):
114
114
Returns:
115
115
The decayed learning rate
116
116
"""
117
- global_step = float_global_step ()
117
+ global_step = _decay_step_counter ()
118
118
119
119
with init_on_cpu ():
120
120
div_res = global_step / decay_steps
@@ -151,7 +151,7 @@ def polynomial_decay(learning_rate,
151
151
Returns:
152
152
The decayed learning rate
153
153
"""
154
- global_step = float_global_step ()
154
+ global_step = _decay_step_counter ()
155
155
156
156
with init_on_cpu ():
157
157
if cycle :
@@ -193,7 +193,7 @@ def piecewise_decay(boundaries, values):
193
193
if len (values ) - len (boundaries ) != 1 :
194
194
raise ValueError ("len(values) - len(boundaries) should be 1" )
195
195
196
- global_step = float_global_step ()
196
+ global_step = _decay_step_counter ()
197
197
198
198
with init_on_cpu ():
199
199
lr = layers .create_global_var (
0 commit comments