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
ModelZoo
ResNet50_tensorflow
Commits
0e621bb8
"docs/source/zh/index.mdx" did not exist on "ef2ea33c3bc061fffa8bc4ccd640306ca1a1847d"
Commit
0e621bb8
authored
Aug 27, 2016
by
Michael Figurnov
Browse files
Refactoring of precision calculation.
Uses more NumPy now :)
parent
a5c4fd06
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
15 deletions
+5
-15
resnet/resnet_main.py
resnet/resnet_main.py
+5
-15
No files found.
resnet/resnet_main.py
View file @
0e621bb8
...
...
@@ -61,9 +61,6 @@ def train(hps):
sess
=
sv
.
prepare_or_wait_for_session
()
step
=
0
total_prediction
=
0
correct_prediction
=
0
precision
=
0.0
lrn_rate
=
0.1
while
not
sv
.
should_stop
():
...
...
@@ -81,14 +78,9 @@ def train(hps):
else
:
lrn_rate
=
0.0001
predictions
=
np
.
argmax
(
predictions
,
axis
=
1
)
truth
=
np
.
argmax
(
truth
,
axis
=
1
)
for
(
t
,
p
)
in
zip
(
truth
,
predictions
):
if
t
==
p
:
correct_prediction
+=
1
total_prediction
+=
1
precision
=
float
(
correct_prediction
)
/
total_prediction
correct_prediction
=
total_prediction
=
0
predictions
=
np
.
argmax
(
predictions
,
axis
=
1
)
precision
=
np
.
mean
(
truth
==
predictions
)
step
+=
1
if
step
%
100
==
0
:
...
...
@@ -135,12 +127,10 @@ def evaluate(hps):
[
model
.
summaries
,
model
.
cost
,
model
.
predictions
,
model
.
labels
,
model
.
global_step
])
best_predictions
=
np
.
argmax
(
predictions
,
axis
=
1
)
truth
=
np
.
argmax
(
truth
,
axis
=
1
)
for
(
t
,
p
)
in
zip
(
truth
,
best_predictions
):
if
t
==
p
:
correct_prediction
+=
1
total_prediction
+=
1
predictions
=
np
.
argmax
(
predictions
,
axis
=
1
)
correct_prediction
+=
np
.
sum
(
truth
==
predictions
)
total_prediction
+=
predictions
.
shape
[
0
]
precision
=
1.0
*
correct_prediction
/
total_prediction
best_precision
=
max
(
precision
,
best_precision
)
...
...
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