Skip to content

Commit 7dd02da

Browse files
evgri243meta-codesync[bot]
authored andcommitted
Fix failing tests (#793)
Summary: - Increased tolerance for gradient comparison test from `1e-7` to `2e-7` in `conv2d_test.py`. - Added GRU validator imports in `validators/__init__.py`. - Disabled downloading of pretrained weights in PrivacyEngine test. ## Types of changes - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Docs change / refactoring / dependency upgrade ## Motivation and Context / Related issue I experience a few failing tests in local setup, this minor changes seems to fix them. ## Checklist - [x] The documentation is up-to-date with the changes I made. - [x] I have read the **CONTRIBUTING** document and completed the CLA (see **CONTRIBUTING**). - [x] All tests passed, and additional code has been covered with new tests. Pull Request resolved: #793 Reviewed By: iden-kalemaj Differential Revision: D85085351 fbshipit-source-id: 98a6533fea393448ad78382cbdcf17240a23ffc6
1 parent 8516d82 commit 7dd02da

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

opacus/tests/grad_samples/conv2d_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,5 +168,5 @@ def test_asymetric_dilation_and_kernel_size(self) -> None:
168168
y.backward(backprops)
169169

170170
self.assertLess(
171-
torch.norm(m._module.weight.grad_sample[0] - m._module.weight.grad), 1e-7
171+
torch.norm(m._module.weight.grad_sample[0] - m._module.weight.grad), 2e-7
172172
)

opacus/tests/privacy_engine_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ def test_validator_weight_update_check(self) -> None:
492492
Test that the privacy engine raises error if ModuleValidator.fix(model) is
493493
called after the optimizer is created
494494
"""
495-
model = models.densenet121(pretrained=True)
495+
model = models.densenet121(weights=None)
496496
num_ftrs = model.classifier.in_features
497497
model.classifier = nn.Sequential(nn.Linear(num_ftrs, 10), nn.Sigmoid())
498498
optimizer = torch.optim.SGD(

opacus/validators/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
# on respective methods
2020

2121
from .batch_norm import fix, validate # noqa
22+
from .gru import fix, validate # noqa
2223
from .instance_norm import fix, validate # noqa
2324
from .lstm import fix, validate # noqa
2425
from .module_validator import ModuleValidator

0 commit comments

Comments
 (0)