Commit 05ba3f53 authored by Surgan Jandial's avatar Surgan Jandial Committed by Francisco Massa
Browse files

Doc, Test Fixes in Normalize (#1063)

* updates on normalize

* test fixes

* Update test_transforms.py
parent 36158026
...@@ -820,6 +820,11 @@ class Tester(unittest.TestCase): ...@@ -820,6 +820,11 @@ class Tester(unittest.TestCase):
# Checking if Normalize can be printed as string # Checking if Normalize can be printed as string
transforms.Normalize(mean, std).__repr__() transforms.Normalize(mean, std).__repr__()
# Checking the optional in-place behaviour
tensor = torch.rand((1, 16, 16))
tensor_inplace = transforms.Normalize((0.5,), (0.5,), inplace=True)(tensor)
assert torch.equal(tensor, tensor_inplace)
def test_normalize_different_dtype(self): def test_normalize_different_dtype(self):
for dtype1 in [torch.float32, torch.float64]: for dtype1 in [torch.float32, torch.float64]:
img = torch.rand(3, 10, 10, dtype=dtype1) img = torch.rand(3, 10, 10, dtype=dtype1)
......
...@@ -200,6 +200,7 @@ def normalize(tensor, mean, std, inplace=False): ...@@ -200,6 +200,7 @@ def normalize(tensor, mean, std, inplace=False):
tensor (Tensor): Tensor image of size (C, H, W) to be normalized. tensor (Tensor): Tensor image of size (C, H, W) to be normalized.
mean (sequence): Sequence of means for each channel. mean (sequence): Sequence of means for each channel.
std (sequence): Sequence of standard deviations for each channel. std (sequence): Sequence of standard deviations for each channel.
inplace(bool,optional): Bool to make this operation inplace.
Returns: Returns:
Tensor: Normalized Tensor image. Tensor: Normalized Tensor image.
......
...@@ -146,6 +146,8 @@ class Normalize(object): ...@@ -146,6 +146,8 @@ class Normalize(object):
Args: Args:
mean (sequence): Sequence of means for each channel. mean (sequence): Sequence of means for each channel.
std (sequence): Sequence of standard deviations for each channel. std (sequence): Sequence of standard deviations for each channel.
inplace(bool,optional): Bool to make this operation in-place.
""" """
def __init__(self, mean, std, inplace=False): def __init__(self, mean, std, inplace=False):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment