Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Max Ehrlich
cdcnn
Commits
5ab3c802
Verified
Commit
5ab3c802
authored
Dec 04, 2018
by
Max Ehrlich
Browse files
Fix label datatype
parent
5726be9f
Changes
2
Hide whitespace changes
Inline
Side-by-side
data/jpeg_readwrite.py
View file @
5ab3c802
...
...
@@ -18,4 +18,4 @@ def load_jpeg(directory, fname):
data
=
dl
[
'data'
]
labels
=
dl
[
'labels'
]
return
torch
.
Tensor
(
data
),
torch
.
Tensor
(
labels
)
return
torch
.
Tensor
(
data
),
torch
.
Long
Tensor
(
labels
)
models/utils.py
View file @
5ab3c802
...
...
@@ -25,8 +25,8 @@ def test(model, device, test_loader):
for
data
,
target
in
test_loader
:
data
,
target
=
data
.
to
(
device
),
target
.
to
(
device
)
output
=
model
(
data
)
test_loss
+=
F
.
cross_entropy
(
output
,
target
,
reduction
=
'sum'
).
item
()
# sum up batch loss
pred
=
output
.
max
(
1
,
keepdim
=
True
)[
1
]
# get the index of the max log-probability
test_loss
+=
F
.
cross_entropy
(
output
,
target
,
reduction
=
'sum'
).
item
()
pred
=
output
.
max
(
1
,
keepdim
=
True
)[
1
]
correct
+=
pred
.
eq
(
target
.
view_as
(
pred
)).
sum
().
item
()
test_loss
/=
len
(
test_loader
.
dataset
)
...
...
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