Commit 56b973b5 authored by Alykhan Tejani's avatar Alykhan Tejani
Browse files

add docs for the Normalize transform

parent b5d03f59
...@@ -127,12 +127,11 @@ def normalize(tensor, mean, std): ...@@ -127,12 +127,11 @@ def normalize(tensor, mean, std):
Args: Args:
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 R, G, B channels respecitvely. mean (sequence): Sequence of means for each channel.
std (sequence): Sequence of standard deviations for R, G, B channels std (sequence): Sequence of standard deviations for each channely.
respecitvely.
Returns: Returns:
Tensor: Normalized image. Tensor: Normalized Tensor image.
""" """
if not _is_tensor_image(tensor): if not _is_tensor_image(tensor):
raise TypeError('tensor is not a torch image.') raise TypeError('tensor is not a torch image.')
...@@ -557,15 +556,13 @@ class ToPILImage(object): ...@@ -557,15 +556,13 @@ class ToPILImage(object):
class Normalize(object): class Normalize(object):
"""Normalize an tensor image with mean and standard deviation. """Normalize an tensor image with mean and standard deviation.
Given mean: ``(M1,...,Mn)`` and std: ``(M1,..,Mn)`` for ``n`` channels, this transform
Given mean: (R, G, B) and std: (R, G, B), will normalize each channel of the input ``torch.*Tensor`` i.e.
will normalize each channel of the torch.*Tensor, i.e. ``input[channel] = (input[channel] - mean[channel]) / std[channel]``
channel = (channel - mean) / std
Args: Args:
mean (sequence): Sequence of means for R, G, B channels respecitvely. mean (sequence): Sequence of means for each channel.
std (sequence): Sequence of standard deviations for R, G, B channels std (sequence): Sequence of standard deviations for each channel.
respecitvely.
""" """
def __init__(self, mean, std): def __init__(self, mean, std):
...@@ -578,7 +575,7 @@ class Normalize(object): ...@@ -578,7 +575,7 @@ class Normalize(object):
tensor (Tensor): Tensor image of size (C, H, W) to be normalized. tensor (Tensor): Tensor image of size (C, H, W) to be normalized.
Returns: Returns:
Tensor: Normalized image. Tensor: Normalized Tensor image.
""" """
return normalize(tensor, self.mean, self.std) return normalize(tensor, self.mean, self.std)
......
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