Skip to content

Commit

Permalink
Added eps in the __repr__ of FrozenBN (#2852)
Browse files Browse the repository at this point in the history
* feat: Updated FrozenBN eps to align with BatchNorm

* feat: Added eps to __repr__ of FrozenBN

* test: Updated unittest of __repr__ for FrozenBN

* test: Updated unittest for eps value in BN and FrozenBN

* fix: Revert FrozenBN eps value

* test: Revert test on eps alignment between FrozenBN and BN
  • Loading branch information
frgfm authored Oct 21, 2020
1 parent 6713f03 commit 005355b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,11 @@ def script_func(x_, offset_, weight_, bias_, stride_, pad_, dilation_):
class FrozenBNTester(unittest.TestCase):
def test_frozenbatchnorm2d_repr(self):
num_features = 32
t = ops.misc.FrozenBatchNorm2d(num_features)
eps = 1e-5
t = ops.misc.FrozenBatchNorm2d(num_features, eps=eps)

# Check integrity of object __repr__ attribute
expected_string = f"FrozenBatchNorm2d({num_features})"
expected_string = f"FrozenBatchNorm2d({num_features}, eps={eps})"
self.assertEqual(t.__repr__(), expected_string)

def test_frozenbatchnorm2d_eps(self):
Expand Down
2 changes: 1 addition & 1 deletion torchvision/ops/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ def forward(self, x: Tensor) -> Tensor:
return x * scale + bias

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.weight.shape[0]})"
return f"{self.__class__.__name__}({self.weight.shape[0]}, eps={self.eps})"

0 comments on commit 005355b

Please sign in to comment.