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
apex
Commits
9ccebe5b
"tests/L0/git@developer.sourcefind.cn:OpenDAS/apex.git" did not exist on "2c6c0f288f94ad4af439c74bc24f8db79dfe2886"
Commit
9ccebe5b
authored
Dec 04, 2018
by
ptrblck
Browse files
call .float() on GPU, remove unnecessary push to GPU
parent
28bdc04e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
3 deletions
+1
-3
examples/distributed/main.py
examples/distributed/main.py
+1
-1
examples/imagenet/main_fp16_optimizer.py
examples/imagenet/main_fp16_optimizer.py
+0
-2
No files found.
examples/distributed/main.py
View file @
9ccebe5b
...
@@ -175,7 +175,7 @@ def test():
...
@@ -175,7 +175,7 @@ def test():
output
=
model
(
data
)
output
=
model
(
data
)
test_loss
+=
to_python_float
(
F
.
nll_loss
(
output
,
target
,
size_average
=
False
).
data
)
# sum up batch loss
test_loss
+=
to_python_float
(
F
.
nll_loss
(
output
,
target
,
size_average
=
False
).
data
)
# sum up batch loss
pred
=
output
.
data
.
max
(
1
,
keepdim
=
True
)[
1
]
# get the index of the max log-probability
pred
=
output
.
data
.
max
(
1
,
keepdim
=
True
)[
1
]
# get the index of the max log-probability
correct
+=
pred
.
eq
(
target
.
data
.
view_as
(
pred
)).
cpu
().
float
().
sum
()
correct
+=
pred
.
eq
(
target
.
data
.
view_as
(
pred
)).
float
().
cpu
().
sum
()
test_loss
/=
len
(
test_loader
.
dataset
)
test_loss
/=
len
(
test_loader
.
dataset
)
...
...
examples/imagenet/main_fp16_optimizer.py
View file @
9ccebe5b
...
@@ -371,8 +371,6 @@ def validate(val_loader, model, criterion):
...
@@ -371,8 +371,6 @@ def validate(val_loader, model, criterion):
while
input
is
not
None
:
while
input
is
not
None
:
i
+=
1
i
+=
1
target
=
target
.
cuda
(
async
=
True
)
# compute output
# compute output
with
torch
.
no_grad
():
with
torch
.
no_grad
():
output
=
model
(
input
)
output
=
model
(
input
)
...
...
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