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
b64919aa
Commit
b64919aa
authored
Feb 24, 2018
by
MTDzi
Browse files
Corrected number of shots in learning to remember rare events
parent
4d1f67cf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
research/learning_to_remember_rare_events/train.py
research/learning_to_remember_rare_events/train.py
+6
-5
No files found.
research/learning_to_remember_rare_events/train.py
View file @
b64919aa
...
...
@@ -197,7 +197,8 @@ class Trainer(object):
# validation
correct
=
[]
correct_by_shot
=
dict
((
k
,
[])
for
k
in
xrange
(
self
.
episode_width
+
1
))
num_shots
=
episode_length
//
episode_width
correct_by_shot
=
dict
((
k
,
[])
for
k
in
xrange
(
num_shots
))
for
_
in
xrange
(
FLAGS
.
validation_length
):
x
,
y
=
self
.
sample_episode_batch
(
valid_data
,
episode_length
,
episode_width
,
1
)
...
...
@@ -213,16 +214,16 @@ class Trainer(object):
# loop over batch examples
for
k
,
(
yyy
,
yyy_preds
)
in
enumerate
(
zip
(
yy
,
yy_preds
)):
yyy
,
yyy_preds
=
int
(
yyy
),
int
(
yyy_preds
)
count
=
seen_counts
[
k
][
yyy
%
self
.
episode_width
]
count
=
seen_counts
[
k
][
yyy
%
episode_width
]
if
count
in
correct_by_shot
:
correct_by_shot
[
count
].
append
(
self
.
individual_compute_correct
(
yyy
,
yyy_preds
))
seen_counts
[
k
][
yyy
%
self
.
episode_width
]
=
count
+
1
seen_counts
[
k
][
yyy
%
episode_width
]
=
count
+
1
logging
.
info
(
'validation overall accuracy %f'
,
np
.
mean
(
correct
))
logging
.
info
(
'%d-shot: %.3f, '
*
(
self
.
episode_width
+
1
)
,
logging
.
info
(
'%d-shot: %.3f, '
*
num_shots
,
*
sum
([[
k
,
np
.
mean
(
correct_by_shot
[
k
])]
for
k
in
xrange
(
self
.
episode_width
+
1
)],
[]))
for
k
in
xrange
(
num_shots
)],
[]))
if
saver
and
FLAGS
.
save_dir
:
saved_file
=
saver
.
save
(
sess
,
...
...
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