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
da67a1e9
Commit
da67a1e9
authored
May 28, 2018
by
Holger Kohr
Committed by
Francisco Massa
May 28, 2018
Browse files
Partially revert #519 due to performance regression & other issues (#521)
parent
cf65f394
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
test/test_transforms.py
test/test_transforms.py
+1
-1
torchvision/transforms/functional.py
torchvision/transforms/functional.py
+4
-3
No files found.
test/test_transforms.py
View file @
da67a1e9
...
@@ -652,7 +652,7 @@ class Tester(unittest.TestCase):
...
@@ -652,7 +652,7 @@ class Tester(unittest.TestCase):
# Checking if RandomHorizontalFlip can be printed as string
# Checking if RandomHorizontalFlip can be printed as string
transforms
.
RandomHorizontalFlip
().
__repr__
()
transforms
.
RandomHorizontalFlip
().
__repr__
()
@
unittest
.
skipIf
(
stats
is
None
,
'scip
t
.stats is not available'
)
@
unittest
.
skipIf
(
stats
is
None
,
'scip
y
.stats is not available'
)
def
test_normalize
(
self
):
def
test_normalize
(
self
):
def
samples_from_standard_normal
(
tensor
):
def
samples_from_standard_normal
(
tensor
):
p_value
=
stats
.
kstest
(
list
(
tensor
.
view
(
-
1
)),
'norm'
,
args
=
(
0
,
1
)).
pvalue
p_value
=
stats
.
kstest
(
list
(
tensor
.
view
(
-
1
)),
'norm'
,
args
=
(
0
,
1
)).
pvalue
...
...
torchvision/transforms/functional.py
View file @
da67a1e9
...
@@ -167,9 +167,10 @@ def normalize(tensor, mean, std):
...
@@ -167,9 +167,10 @@ def normalize(tensor, mean, std):
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.'
)
mean
=
torch
.
Tensor
(
mean
).
view
((
tensor
.
shape
[
0
],
1
,
1
))
# This is faster than using broadcasting, don't change without benchmarking
std
=
torch
.
Tensor
(
std
).
view
((
tensor
.
shape
[
0
],
1
,
1
))
for
t
,
m
,
s
in
zip
(
tensor
,
mean
,
std
):
return
tensor
.
sub_
(
mean
).
div_
(
std
)
t
.
sub_
(
m
).
div_
(
s
)
return
tensor
def
resize
(
img
,
size
,
interpolation
=
Image
.
BILINEAR
):
def
resize
(
img
,
size
,
interpolation
=
Image
.
BILINEAR
):
...
...
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