Skip to content

Commit

Permalink
✅ Finish bayesian test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
o-laurent committed Aug 25, 2023
1 parent c25a61f commit 368c1e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/layers/test_bayesian_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,21 @@ def test_conv1_even(self, feat_input_even: torch.Tensor) -> None:
layer = BayesConv1d(
8, 2, kernel_size=1, sigma_init=0, padding_mode="reflect"
)
print(layer)
out = layer(feat_input_even)
assert out.shape == torch.Size([2, 10])

layer.freeze()
out = layer(feat_input_even)

layer.__setstate__({"padding_mode": "replicate"})

def test_error(self):
with pytest.raises(ValueError):
BayesConv1d(
8, 2, kernel_size=1, sigma_init=0, padding_mode="random"
)


class TestBayesConv2d:
"""Testing the BayesConv2d layer class."""
Expand All @@ -113,6 +122,7 @@ def test_conv2_even(self, img_input_even: torch.Tensor) -> None:
layer = BayesConv2d(
10, 2, kernel_size=1, sigma_init=0, padding_mode="reflect"
)
print(layer)
out = layer(img_input_even)
assert out.shape == torch.Size([8, 2, 3, 3])

Expand All @@ -130,13 +140,15 @@ def test_conv3(self, cube_input_odd: torch.Tensor) -> None:
assert out.shape == torch.Size([1, 2, 3, 3, 3])

layer = BayesConv3d(10, 2, kernel_size=1, sigma_init=0, bias=False)
print(layer)
out = layer(cube_input_odd)
assert out.shape == torch.Size([1, 2, 3, 3, 3])

def test_conv3_even(self, cube_input_even: torch.Tensor) -> None:
layer = BayesConv3d(
10, 2, kernel_size=1, sigma_init=0, padding_mode="reflect"
)
print(layer)
out = layer(cube_input_even)
assert out.shape == torch.Size([2, 2, 3, 3, 3])

Expand Down

0 comments on commit 368c1e9

Please sign in to comment.