Skip to content

Commit 3842edc

Browse files
Googlercopybara-github
authored andcommitted
De-couple tensors used by the initializers of in parameterizers.py
from the one used by the reparameterizers. PiperOrigin-RevId: 268086959 Change-Id: Ia873a613f0ad8aa1fa15262d82f65b97c751e208
1 parent 7a1d6bd commit 3842edc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tensorflow_compression/python/layers/parameterizers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ def __call__(self, getter, name, shape, dtype, initializer, regularizer=None):
179179
reparam_name = "reparam_" + name
180180

181181
def reparam_initializer(shape, dtype=None, partition_info=None):
182+
# We recreate pedestal to decouple the initializer from the model graph.
183+
pedestal = tf.constant(self.reparam_offset ** 2, dtype=dtype)
182184
init = initializer(shape, dtype=dtype, partition_info=partition_info)
183185
init = tf.math.sqrt(tf.math.maximum(init + pedestal, pedestal))
184186
return init

0 commit comments

Comments
 (0)