Skip to content

Commit

Permalink
fix(callbacks): Keras SVD op is not as expected
Browse files Browse the repository at this point in the history
SVD operation in Keras 3 does not handle "compute_uv". Bug was fixed
in Keras 3.6.0 (next version to be released). Waiting for this version,
a hot fix is used where we compute u and v for nothing.

This commit could be reverted when Keras 3.6 is released.
  • Loading branch information
cofri committed Sep 6, 2024
1 parent af29744 commit 3626290
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions deel/lip/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,12 @@ def _monitor(self, step):
elif hasattr(layer, self.target):
kernel = getattr(layer, self.target)
w_shape = kernel.shape.as_list()
# TODO: compute_uv=False in next Keras version (3.6.0)
sigmas = K.svd(
K.reshape(kernel, [-1, w_shape[-1]]),
full_matrices=False,
compute_uv=False,
).numpy()
compute_uv=True,
)[1].numpy()
sig = sigmas[0]
else:
raise RuntimeWarning(
Expand Down

0 comments on commit 3626290

Please sign in to comment.