Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
56b973b5
Commit
56b973b5
authored
Oct 12, 2017
by
Alykhan Tejani
Browse files
add docs for the Normalize transform
parent
b5d03f59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
12 deletions
+9
-12
torchvision/transforms.py
torchvision/transforms.py
+9
-12
No files found.
torchvision/transforms.py
View file @
56b973b5
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment