Skip to content

Commit 8eccacd

Browse files
authored
Initialized lr with a small value (#2477)
1 parent 356ba48 commit 8eccacd

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tensorflow_addons/optimizers/cocob.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
1+
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -46,7 +46,6 @@ def __init__(
4646
Rasies:
4747
`ValueError`: If the value of `alpha` is less than 1.
4848
`NotImplementedError`: If the data is in sparse format.
49-
5049
"""
5150

5251
if alpha < 1:
@@ -58,7 +57,7 @@ def __init__(
5857

5958
def _create_slots(self, var_list):
6059
for v in var_list:
61-
self.add_slot(v, "L")
60+
self.add_slot(v, "lr", initializer=tf.keras.initializers.Constant(1e-8))
6261
self.add_slot(v, "grad_norm_sum")
6362
self.add_slot(v, "gradients_sum")
6463
self.add_slot(v, "tilde_w")
@@ -68,7 +67,7 @@ def _resource_apply_dense(self, grad, handle, apply_state=None):
6867
gradients_sum = self.get_slot(handle, "gradients_sum")
6968
grad_norm_sum = self.get_slot(handle, "grad_norm_sum")
7069
tilde_w = self.get_slot(handle, "tilde_w")
71-
lr = self.get_slot(handle, "L")
70+
lr = self.get_slot(handle, "lr")
7271
reward = self.get_slot(handle, "reward")
7372

7473
lr_update = tf.maximum(lr, tf.abs(grad))

0 commit comments

Comments
 (0)