tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.49k stars 1.67k forks source link

Performance issue in /examples/image_retraining (by P3) #799

Closed DLPerf closed 2 years ago

DLPerf commented 3 years ago

Hello! I've found a performance issue in /examples/image_retraining/retrain.py: eval_sess = tf.Session(graph=eval_graph)(here) is defined in the function build_eval_session(here) which is called in the function save_graph_to_file(here) which is repeatedly called in the loop for i in range(FLAGS.how_many_training_steps)(here).

tf.Session being defined repeatedly could lead to incremental overhead. If you define tf.Session out of the loop and pass tf.Session as a parameter to the loop, your program would be much more efficient. Here is the Stack Overflow post to support it.

Looking forward to your reply. Btw, I am very glad to create a PR to fix it if you are too busy.

MorganR commented 3 years ago

Hi @DLPerf, this code is also deprecated, but you are always welcome to file a PR to improve things.

UsharaniPagadala commented 3 years ago

@DLPerf

Could you please confirm if you have filed the PR mentioned.Thanks

singhniraj08 commented 2 years ago

@DLPerf,

This code is deprecated, still you can create a PR with fix to improve performance. Thank you for contributing!

WGierke commented 2 years ago

Closing due to inactivity.