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
68bb2534
Commit
68bb2534
authored
Apr 08, 2019
by
Ashok M
Committed by
Francisco Massa
Apr 08, 2019
Browse files
Added test for normalize functionality in make_grid function. (#840)
parent
0d975d6d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
test/test_utils.py
test/test_utils.py
+17
-0
No files found.
test/test_utils.py
View file @
68bb2534
...
@@ -18,6 +18,23 @@ class Tester(unittest.TestCase):
...
@@ -18,6 +18,23 @@ class Tester(unittest.TestCase):
utils
.
make_grid
(
t
,
normalize
=
True
,
scale_each
=
True
)
utils
.
make_grid
(
t
,
normalize
=
True
,
scale_each
=
True
)
assert
torch
.
equal
(
t
,
t_clone
),
'make_grid modified tensor in-place'
assert
torch
.
equal
(
t
,
t_clone
),
'make_grid modified tensor in-place'
def
test_normalize_in_make_grid
(
self
):
t
=
torch
.
rand
(
5
,
3
,
10
,
10
)
*
255
norm_max
=
torch
.
tensor
(
1.0
)
norm_min
=
torch
.
tensor
(
0.0
)
grid
=
utils
.
make_grid
(
t
,
normalize
=
True
)
grid_max
=
torch
.
max
(
grid
)
grid_min
=
torch
.
min
(
grid
)
# Rounding the result to one decimal for comparison
n_digits
=
1
rounded_grid_max
=
torch
.
round
(
grid_max
*
10
**
n_digits
)
/
(
10
**
n_digits
)
rounded_grid_min
=
torch
.
round
(
grid_min
*
10
**
n_digits
)
/
(
10
**
n_digits
)
assert
torch
.
equal
(
norm_max
,
rounded_grid_max
),
'Normalized max is not equal to 1'
assert
torch
.
equal
(
norm_min
,
rounded_grid_min
),
'Normalized min is not equal to 0'
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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