File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
tensorflow_model_optimization/python/core/sparsity/keras Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -209,14 +209,14 @@ def build(self, input_shape):
209
209
210
210
# For each of the prunable weights, add mask and threshold variables
211
211
for weight in self .prunable_weights :
212
- mask = self .add_variable (
212
+ mask = self .add_weight (
213
213
'mask' ,
214
214
shape = weight .shape ,
215
215
initializer = tf .keras .initializers .get ('ones' ),
216
216
dtype = weight .dtype ,
217
217
trainable = False ,
218
218
aggregation = tf .VariableAggregation .MEAN )
219
- threshold = self .add_variable (
219
+ threshold = self .add_weight (
220
220
'threshold' ,
221
221
shape = [],
222
222
initializer = tf .keras .initializers .get ('zeros' ),
@@ -230,7 +230,7 @@ def build(self, input_shape):
230
230
self .pruning_vars = list (zip (weight_vars , mask_vars , threshold_vars ))
231
231
232
232
# Add a scalar tracking the number of updates to the wrapped layer.
233
- self .pruning_step = self .add_variable (
233
+ self .pruning_step = self .add_weight (
234
234
'pruning_step' ,
235
235
shape = [],
236
236
initializer = tf .keras .initializers .Constant (- 1 ),
You can’t perform that action at this time.
0 commit comments