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
05ba3f53
Commit
05ba3f53
authored
Jun 28, 2019
by
Surgan Jandial
Committed by
Francisco Massa
Jun 28, 2019
Browse files
Doc, Test Fixes in Normalize (#1063)
* updates on normalize * test fixes * Update test_transforms.py
parent
36158026
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
0 deletions
+8
-0
test/test_transforms.py
test/test_transforms.py
+5
-0
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+1
-0
torchvision/transforms/transforms.py
torchvision/transforms/transforms.py
+2
-0
No files found.
test/test_transforms.py
View file @
05ba3f53
...
...
@@ -820,6 +820,11 @@ class Tester(unittest.TestCase):
# Checking if Normalize can be printed as string
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
):
for
dtype1
in
[
torch
.
float32
,
torch
.
float64
]:
img
=
torch
.
rand
(
3
,
10
,
10
,
dtype
=
dtype1
)
...
...
torchvision/transforms/functional.py
View file @
05ba3f53
...
...
@@ -200,6 +200,7 @@ def normalize(tensor, mean, std, inplace=False):
tensor (Tensor): Tensor image of size (C, H, W) to be normalized.
mean (sequence): Sequence of means for each channel.
std (sequence): Sequence of standard deviations for each channel.
inplace(bool,optional): Bool to make this operation inplace.
Returns:
Tensor: Normalized Tensor image.
...
...
torchvision/transforms/transforms.py
View file @
05ba3f53
...
...
@@ -146,6 +146,8 @@ class Normalize(object):
Args:
mean (sequence): Sequence of means 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
):
...
...
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