Skip to content

Commit

Permalink
Merge pull request #13 from deel-ai/fix-ci
Browse files Browse the repository at this point in the history
Fix Github Action
  • Loading branch information
Holt59 committed Jul 17, 2020
2 parents 8b1b245 + db7c913 commit d062528
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
pip install tox
- name: Test with tox
run: tox -e py36-lint
6 changes: 2 additions & 4 deletions deel/lip/initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
@_deel_export
class SpectralInitializer(Initializer):
def __init__(
self,
niter_spectral=3,
base_initializer=Orthogonal(gain=1., seed=None),
self, niter_spectral=3, base_initializer=Orthogonal(gain=1.0, seed=None),
) -> None:
"""
Initialize a kernel to be 1-lipschitz using spectral normalization (iterative
Expand Down Expand Up @@ -48,7 +46,7 @@ def __init__(
self,
niter_spectral=3,
niter_bjorck=15,
base_initializer=Orthogonal(gain=1., seed=None),
base_initializer=Orthogonal(gain=1.0, seed=None),
) -> None:
"""
Initialize a kernel to be 1-lipschitz almost everywhere using bjorck
Expand Down
8 changes: 4 additions & 4 deletions deel/lip/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ def build(self, input_shape):
initializer=RandomNormal(0, 1),
name="sn",
trainable=False,
dtype=self.dtype
dtype=self.dtype,
)

self.sig = self.add_weight(
shape=tuple([1, 1]), # maximum spectral value
name="sigma",
trainable=False,
dtype=self.dtype
dtype=self.dtype,
)
self.sig.assign([[1.0]])
self.built = True
Expand Down Expand Up @@ -462,14 +462,14 @@ def build(self, input_shape):
initializer=RandomNormal(0, 1),
name="sn",
trainable=False,
dtype=self.dtype
dtype=self.dtype,
)

self.sig = self.add_weight(
shape=tuple([1, 1]), # maximum spectral value
name="sigma",
trainable=False,
dtype=self.dtype
dtype=self.dtype,
)
self.sig.assign([[1.0]])
self.built = True
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ commands =
python -m unittest

[testenv:py36-lint]
skip_install = true
deps =
black
flake8
Expand Down
6 changes: 1 addition & 5 deletions tests/test_initializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
from tensorflow.keras import backend as K, metrics
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import Adam
from tests.test_layers import linear_generator, build_kernel
from deel.lip.initializers import SpectralInitializer, BjorckInitializer
from deel.lip.utils import evaluate_lip_const

FIT = "fit_generator" if tf.__version__.startswith("2.0") else "fit"
EVALUATE = "evaluate_generator" if tf.__version__.startswith("2.0") else "evaluate"
Expand Down Expand Up @@ -45,9 +43,7 @@ def _test_model(self, model, input_shape):
)
model.build((batch_size,) + input_shape)
sigmas = tf.linalg.svd(
model.layers[0].kernel,
full_matrices=False,
compute_uv=False,
model.layers[0].kernel, full_matrices=False, compute_uv=False,
).numpy()
np.testing.assert_allclose(sigmas, np.ones_like(sigmas), 1e-6, 0)

Expand Down

0 comments on commit d062528

Please sign in to comment.