@@ -46,10 +46,12 @@ class Optimizer(object):
46
46
def __init__ (self ,
47
47
learning_rate ,
48
48
regularization = None ,
49
- LARS_weight_decay = 0.0 ):
49
+ LARS_weight_decay = 0.0 ,
50
+ name = None ):
50
51
if not isinstance (learning_rate , float ) and \
51
52
not isinstance (learning_rate , framework .Variable ):
52
53
raise TypeError ("learning rate should be float or Variable" )
54
+ self ._name = name
53
55
self .regularization = regularization
54
56
self ._learning_rate = learning_rate
55
57
# the learning rate type should be inferenced from loss
@@ -153,6 +155,8 @@ def _add_accumulator(self,
153
155
dtype: data type of the accumulator variable
154
156
fill_value: value to initialize the accumulator variable
155
157
"""
158
+ if self ._name is not None :
159
+ name = self ._name + "_" + name
156
160
if (name in self ._accumulators and
157
161
param .name in self ._accumulators [name ]):
158
162
raise Exception ("Accumulator {} already exists for parameter {}" .
@@ -181,6 +185,8 @@ def _get_accumulator(self, name, param):
181
185
Returns:
182
186
accumulator variable for the parameter
183
187
"""
188
+ if self ._name is not None :
189
+ name = self ._name + "_" + name
184
190
if (name not in self ._accumulators or
185
191
param .name not in self ._accumulators [name ]):
186
192
raise Exception ("Accumulator {} does not exist for parameter {}" .
0 commit comments