Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added number of features in FrozenBatchNorm2d __repr__ #2168

Merged
merged 8 commits into from
May 5, 2020
10 changes: 10 additions & 0 deletions test/test_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,15 @@ def script_func(x_, offset_, weight_, bias_, stride_, pad_, dilation_):
(x, offset, weight, bias), nondet_tol=1e-5)


class FrozenBNTester(unittest.TestCase):
def test_frozenbatchnorm2d_repr(self):
num_features = 32
t = ops.misc.FrozenBatchNorm2d(num_features)

# Check integrity of object __repr__ attribute
expected_string = 'FrozenBatchNorm2d({0})'.format(num_features)
frgfm marked this conversation as resolved.
Show resolved Hide resolved
self.assertEqual(t.__repr__(), expected_string)


if __name__ == '__main__':
unittest.main()
3 changes: 3 additions & 0 deletions torchvision/ops/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,6 @@ def forward(self, x):
scale = w * rv.rsqrt()
bias = b - rm * scale
return x * scale + bias

def __repr__(self):
return f"{self.__class__.__name__}({self.weight.shape[0]})"