Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.tensorflow
Commits
eaae3554
Commit
eaae3554
authored
Oct 23, 2017
by
Amir MOHAMMADI
Browse files
remove the graph
parent
7a578d22
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/learn/tensorflow/script/predict_bio.py
View file @
eaae3554
...
...
@@ -160,42 +160,40 @@ def main(argv=None):
output_dir
=
get_from_config_or_commandline
(
config
,
'output_dir'
,
args
,
defaults
,
False
)
with
tf
.
Graph
().
as_default
():
generator
,
output_types
,
output_shapes
=
bio_generator
(
database
,
preprocessor
,
groups
,
number_of_parallel_jobs
,
biofile_to_label
,
multiple_samples
)
predict_input_fn
=
bio_predict_input_fn
(
generator
,
output_types
,
output_shapes
)
predictions
=
estimator
.
predict
(
predict_input_fn
,
predict_keys
=
predict_keys
,
hooks
=
hooks
,
checkpoint_path
=
checkpoint_path
,
)
pool
=
Pool
()
try
:
pred_buffer
=
defaultdict
(
list
)
for
i
,
pred
in
enumerate
(
predictions
):
key
=
pred
[
'keys'
]
prob
=
pred
.
get
(
'probabilities'
,
pred
.
get
(
'embeddings'
))
pred_buffer
[
key
].
append
(
prob
)
if
i
==
0
:
last_key
=
key
if
last_key
==
key
:
continue
else
:
save_predictions
(
pool
,
output_dir
,
last_key
,
pred_buffer
)
last_key
=
key
# else below is for the for loop
generator
,
output_types
,
output_shapes
=
bio_generator
(
database
,
preprocessor
,
groups
,
number_of_parallel_jobs
,
biofile_to_label
,
multiple_samples
)
predict_input_fn
=
bio_predict_input_fn
(
generator
,
output_types
,
output_shapes
)
predictions
=
estimator
.
predict
(
predict_input_fn
,
predict_keys
=
predict_keys
,
hooks
=
hooks
,
checkpoint_path
=
checkpoint_path
,
)
pool
=
Pool
()
try
:
pred_buffer
=
defaultdict
(
list
)
for
i
,
pred
in
enumerate
(
predictions
):
key
=
pred
[
'keys'
]
prob
=
pred
.
get
(
'probabilities'
,
pred
.
get
(
'embeddings'
))
pred_buffer
[
key
].
append
(
prob
)
if
i
==
0
:
last_key
=
key
if
last_key
==
key
:
continue
else
:
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
)
finally
:
pool
.
close
()
pool
.
join
()
save_predictions
(
pool
,
output_dir
,
last_key
,
pred_buffer
)
last_key
=
key
# else below is for the for loop
else
:
save_predictions
(
pool
,
output_dir
,
key
,
pred_buffer
)
finally
:
pool
.
close
()
pool
.
join
()
if
__name__
==
'__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