From 05a20644d94c342e618450998b72b963691ddcc4 Mon Sep 17 00:00:00 2001 From: Marvin Teichmann Date: Wed, 1 Mar 2017 13:38:21 +0000 Subject: [PATCH 1/7] Replace graph with sess as the default entity. This is default in newer Tensorflow versions. Sess can now be initialized before the graph is build and the graph can be obtained using sess.graph. Hence the changes offers better workflow. --- tensorvision/train.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorvision/train.py b/tensorvision/train.py index 0064c00..0819c98 100644 --- a/tensorvision/train.py +++ b/tensorvision/train.py @@ -367,7 +367,7 @@ def do_training(hypes): modules = utils.load_modules_from_hypes(hypes) # Tell TensorFlow that the model will be built into the default Graph. - with tf.Graph().as_default(): + with tf.Session() as sess: # build the graph based on the loaded modules with tf.name_scope("Queues"): @@ -377,12 +377,12 @@ def do_training(hypes): # prepaire the tv session tv_sess = core.start_tv_session(hypes) - sess = tv_sess['sess'] with tf.name_scope('Validation'): tf.get_variable_scope().reuse_variables() image_pl = tf.placeholder(tf.float32) image = tf.expand_dims(image_pl, 0) + image.set_shape([1, None, None, 3]) inf_out = core.build_inference_graph(hypes, modules, image=image) tv_graph['image_pl'] = image_pl @@ -415,7 +415,7 @@ def continue_training(logdir): modules = utils.load_modules_from_logdir(logdir) # Tell TensorFlow that the model will be built into the default Graph. - with tf.Graph().as_default(): + with tf.Session() as sess: # build the graph based on the loaded modules with tf.name_scope("Queues"): @@ -445,6 +445,7 @@ def continue_training(logdir): tf.get_variable_scope().reuse_variables() image_pl = tf.placeholder(tf.float32) image = tf.expand_dims(image_pl, 0) + image.set_shape([1, None, None, 3]) inf_out = core.build_inference_graph(hypes, modules, image=image) tv_graph['image_pl'] = image_pl From aa4b14d05466036be30376b34e3d3a7716a33b6a Mon Sep 17 00:00:00 2001 From: Marvin Teichmann Date: Wed, 1 Mar 2017 13:41:47 +0000 Subject: [PATCH 2/7] Make it possible to define user init functions. If an init function is defined in `hypes['init_function']` the corresponding function will be called instead of the default global initializer. This is important for finetuning. I am not to happy with the current implementation. I will think of a better way to generalize this. --- tensorvision/core.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tensorvision/core.py b/tensorvision/core.py index f906b05..34b1239 100644 --- a/tensorvision/core.py +++ b/tensorvision/core.py @@ -156,15 +156,18 @@ def start_tv_session(hypes): kc = hypes['solver']['keep_checkpoint_every_n_hours'] else: kc = 10000.0 - saver = tf.train.Saver(max_to_keep=int(utils.cfg.max_to_keep), - keep_checkpoint_every_n_hours=kc) - # Create a session for running Ops on the Graph. - sess = tf.Session() + saver = tf.train.Saver(max_to_keep=int(utils.cfg.max_to_keep)) + + sess = tf.get_default_session() # Run the Op to initialize the variables. - init = tf.global_variables_initializer() - sess.run(init) + if 'init_function' in hypes: + _initalize_variables = hypes['init_function'] + _initalize_variables(hypes) + else: + init = tf.global_variables_initializer() + sess.run(init) # Start the queue runners. coord = tf.train.Coordinator() From 50486fe4228e02933a2160e384e5e8daa9f4a5f0 Mon Sep 17 00:00:00 2001 From: Marvin Teichmann Date: Mon, 6 Mar 2017 16:53:42 +0000 Subject: [PATCH 3/7] Add option to disable writing summaries --- tensorvision/core.py | 14 +++++++++++++- tensorvision/train.py | 7 ++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/tensorvision/core.py b/tensorvision/core.py index 34b1239..d48306b 100644 --- a/tensorvision/core.py +++ b/tensorvision/core.py @@ -14,6 +14,12 @@ import tensorvision.utils as utils +flags = tf.app.flags +FLAGS = flags.FLAGS + +tf.app.flags.DEFINE_boolean( + 'summary', True, ('Whether or not to save summaries to tensorboard.')) + def load_weights(checkpoint_dir, sess, saver): """ @@ -107,6 +113,7 @@ def build_training_graph(hypes, queue, modules): graph['train_op'] = train_op graph['global_step'] = global_step graph['learning_rate'] = learning_rate + graph['decoded_logits'] = learning_rate return graph @@ -149,7 +156,12 @@ def start_tv_session(hypes): (sess, saver, summary_op, summary_writer, threads) """ # Build the summary operation based on the TF collection of Summaries. - summary_op = tf.summary.merge_all() + if FLAGS.summary: + tf.contrib.layers.summarize_collection(tf.GraphKeys.WEIGHTS) + tf.contrib.layers.summarize_collection(tf.GraphKeys.BIASES) + summary_op = tf.summary.merge_all() + else: + summary_op = None # Create a saver for writing training checkpoints. if 'keep_checkpoint_every_n_hours' in hypes['solver']: diff --git a/tensorvision/train.py b/tensorvision/train.py index 0819c98..a9e705a 100644 --- a/tensorvision/train.py +++ b/tensorvision/train.py @@ -257,9 +257,10 @@ def run_training(hypes, modules, tv_graph, tv_sess, start_step=0): if step % write_iter == 0: # write values to summary - summary_str = sess.run(tv_sess['summary_op'], - feed_dict=feed_dict) - summary_writer.add_summary(summary_str, global_step=step) + if FLAGS.summary: + summary_str = sess.run(tv_sess['summary_op'], + feed_dict=feed_dict) + summary_writer.add_summary(summary_str, global_step=step) summary.value.add(tag='training/total_loss', simple_value=float(loss_value)) summary.value.add(tag='training/learning_rate', From f922d8f250fd4ed5aa45b335a0b188c60af513c1 Mon Sep 17 00:00:00 2001 From: Marvin Teichmann Date: Mon, 6 Mar 2017 16:59:38 +0000 Subject: [PATCH 4/7] Fix Bug --- tensorvision/analyze.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorvision/analyze.py b/tensorvision/analyze.py index dbf149f..18be429 100644 --- a/tensorvision/analyze.py +++ b/tensorvision/analyze.py @@ -71,6 +71,7 @@ def do_analyze(logdir, base_path=None): image_pl = tf.placeholder(tf.float32) image = tf.expand_dims(image_pl, 0) + image.set_shape([1, None, None, 3]) inf_out = core.build_inference_graph(hypes, modules, image=image) From 0f9a9c1cee19a7bf87f1e699f91df2a9a83c4a8b Mon Sep 17 00:00:00 2001 From: Marvin Teichmann Date: Tue, 7 Mar 2017 19:58:18 +0000 Subject: [PATCH 5/7] Make write indepenend of display --- tensorvision/train.py | 44 +++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/tensorvision/train.py b/tensorvision/train.py index a9e705a..51c7ec7 100644 --- a/tensorvision/train.py +++ b/tensorvision/train.py @@ -221,7 +221,7 @@ def run_training(hypes, modules, tv_graph, tv_sess, start_step=0): save_iter = hypes['logging']['save_iter'] image_iter = hypes['logging'].get('image_iter', 5*save_iter) - py_smoother = MedianSmoother(50) + py_smoother = MedianSmoother(20) dict_smoother = ExpoSmoother(0.95) n = 0 @@ -255,30 +255,30 @@ def run_training(hypes, modules, tv_graph, tv_sess, start_step=0): _print_eval_dict(eval_names, smoothed_results, prefix='(smooth)') - if step % write_iter == 0: - # write values to summary - if FLAGS.summary: - summary_str = sess.run(tv_sess['summary_op'], - feed_dict=feed_dict) - summary_writer.add_summary(summary_str, global_step=step) - summary.value.add(tag='training/total_loss', - simple_value=float(loss_value)) - summary.value.add(tag='training/learning_rate', - simple_value=lr) - summary_writer.add_summary(summary, step) - # Convert numpy types to simple types. - eval_results = np.array(eval_results) - eval_results = eval_results.tolist() - eval_dict = zip(eval_names, eval_results) - _write_eval_dict_to_summary(eval_dict, 'Eval/raw', - summary_writer, step) - eval_dict = zip(eval_names, smoothed_results) - _write_eval_dict_to_summary(eval_dict, 'Eval/smooth', - summary_writer, step) - # Reset timer start_time = time.time() + if step % write_iter == 0: + # write values to summary + if FLAGS.summary: + summary_str = sess.run(tv_sess['summary_op'], + feed_dict=feed_dict) + summary_writer.add_summary(summary_str, global_step=step) + summary.value.add(tag='training/total_loss', + simple_value=float(loss_value)) + summary.value.add(tag='training/learning_rate', + simple_value=lr) + summary_writer.add_summary(summary, step) + # Convert numpy types to simple types. + eval_results = np.array(eval_results) + eval_results = eval_results.tolist() + eval_dict = zip(eval_names, eval_results) + _write_eval_dict_to_summary(eval_dict, 'Eval/raw', + summary_writer, step) + eval_dict = zip(eval_names, smoothed_results) + _write_eval_dict_to_summary(eval_dict, 'Eval/smooth', + summary_writer, step) + # Do a evaluation and print the current state if (step) % eval_iter == 0 and step > 0 or \ (step + 1) == hypes['solver']['max_steps']: From e3637ac170727af5ea2a414160dd8cd372b1c1ff Mon Sep 17 00:00:00 2001 From: Jenny Date: Fri, 26 May 2017 05:45:52 -0400 Subject: [PATCH 6/7] Typo fix (#60) --- tensorvision/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorvision/core.py b/tensorvision/core.py index d48306b..22c56ee 100644 --- a/tensorvision/core.py +++ b/tensorvision/core.py @@ -113,7 +113,7 @@ def build_training_graph(hypes, queue, modules): graph['train_op'] = train_op graph['global_step'] = global_step graph['learning_rate'] = learning_rate - graph['decoded_logits'] = learning_rate + graph['decoded_logits'] = decoded_logits return graph From d971ed2b7d8fe1c0caf407eb7bdaebc0838e5801 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sat, 9 Jun 2018 17:44:44 +0200 Subject: [PATCH 7/7] MAINT: Update development status trove classifier to '7 - Inactive' --- Makefile | 8 ++++++++ README.md | 1 - setup.py | 3 ++- tensorvision/__init__.py | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..073df75 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +upload: + make clean + python3 setup.py sdist bdist_wheel && twine upload dist/* + +clean: + python setup.py clean --all + pyclean . + rm -rf *.pyc __pycache__ build dist tensorvision.egg-info tensorvision/__pycache__ tests/__pycache__ tests/reports docs/build diff --git a/README.md b/README.md index 024e0a8..07df0c7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ [![Documentation Status](https://readthedocs.org/projects/tensorvision/badge/?version=latest)](http://tensorvision.readthedocs.org/en/latest/?badge=latest) -[![Code Issues](https://www.quantifiedcode.com/api/v1/project/3ef49e94e03a42b0bf896f5377c8e741/badge.svg)](https://www.quantifiedcode.com/app/project/3ef49e94e03a42b0bf896f5377c8e741) [![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/ TensorVision/TensorVision/blob/master/LICENSE) diff --git a/setup.py b/setup.py index 25d40a0..e5d9553 100644 --- a/setup.py +++ b/setup.py @@ -45,7 +45,8 @@ description="A library to build and train neural networks " "in with TensorFlow for Computer Vision", long_description="\n\n".join([README, CHANGES]), - classifiers=["Development Status :: 1 - Planning", + long_description_content_type='text/markdown', + classifiers=["Development Status :: 7 - Inactive", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", diff --git a/tensorvision/__init__.py b/tensorvision/__init__.py index a19f475..26e1382 100644 --- a/tensorvision/__init__.py +++ b/tensorvision/__init__.py @@ -1,3 +1,3 @@ """Tools to train neural networks for computer vision in TensorFlow.""" -__version__ = "0.1.dev1" +__version__ = "0.1.dev2"