File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
src/TensorFlowNET.Core/Keras/Optimizers Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ public PolynomialDecay(float initial_learning_rate,
3636
3737 public Tensor __call__ ( RefVariable step )
3838 {
39- tf_with ( ops . name_scope ( name ?? "PolynomialDecay" ) , scope =>
39+ return tf_with ( ops . name_scope ( name ?? "PolynomialDecay" ) , scope =>
4040 {
4141 name = scope ;
4242 var initial_learning_rate_tensor = ops . convert_to_tensor ( initial_learning_rate , name : "initial_learning_rate" ) ;
@@ -53,10 +53,17 @@ public Tensor __call__(RefVariable step)
5353 }
5454 else
5555 {
56-
56+ // Make sure that the global_step used is not bigger than decay_steps.
57+ global_step_recomp = math_ops . minimum ( global_step_recomp , decay_steps ) ;
5758 }
59+
60+ var p = tf . divide ( global_step_recomp , decay_steps_recomp ) ;
61+ var pow = tf . pow ( 1 - p , power_tensor ) ;
62+ var m = math_ops . multiply ( initial_learning_rate_tensor - end_learning_rate_tensor , pow ) ;
63+ return math_ops . add ( m ,
64+ end_learning_rate_tensor ,
65+ name : name ) ;
5866 } ) ;
59- throw new NotImplementedException ( "" ) ;
6067 }
6168 }
6269}
You can’t perform that action at this time.
0 commit comments