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
b5d03f59
Commit
b5d03f59
authored
Oct 12, 2017
by
Alykhan Tejani
Browse files
added tests for transforms.Normalize
parent
12a37ba7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
test/test_transforms.py
test/test_transforms.py
+16
-0
No files found.
test/test_transforms.py
View file @
b5d03f59
...
...
@@ -430,6 +430,22 @@ class Tester(unittest.TestCase):
random
.
setstate
(
random_state
)
assert
p_value
>
0.0001
@
unittest
.
skipIf
(
stats
is
None
,
'scipt.stats is not available'
)
def
test_normalize
(
self
):
def
samples_from_standard_normal
(
tensor
):
p_value
=
stats
.
kstest
(
list
(
tensor
.
view
(
-
1
)),
'norm'
,
args
=
(
0
,
1
)).
pvalue
return
p_value
>
0.0001
random_state
=
random
.
getstate
()
random
.
seed
(
42
)
for
channels
in
[
1
,
3
]:
img
=
torch
.
rand
(
channels
,
10
,
10
)
mean
=
[
img
[
c
].
mean
()
for
c
in
range
(
channels
)]
std
=
[
img
[
c
].
std
()
for
c
in
range
(
channels
)]
normalized
=
transforms
.
Normalize
(
mean
,
std
)(
img
)
assert
samples_from_standard_normal
(
normalized
)
random
.
setstate
(
random_state
)
def
test_adjust_brightness
(
self
):
x_shape
=
[
2
,
2
,
3
]
x_data
=
[
0
,
5
,
13
,
54
,
135
,
226
,
37
,
8
,
234
,
90
,
255
,
1
]
...
...
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