python 2.7 - tensorflow group or collect fetches ops or tensors into single fetch -


i general case tf.merge_all_summaries tf.get_collection('summaries').

as example, find tf.contrib.metrics.streaming* suite introduces set of "update_op" operations must run once each. find following syntax cumbersome,

_,_,_,_,_,summary,_=sess.run( tf.get_collection('updates')+[merged_summaries]+[train_op]) 

and looking workaround not require knowing number of updates in collection. using tensorflow-0.10 of writing.

tensorflow supports (since version 0.10) passing nested structures session.run(). example, can pass list of lists of tf.tensor objects session.run() , result similarly-nested list of lists of numpy arrays. can pass mixed list (or tuple) containing lists, tensors, , operations. in case, write following:

updates = tf.get_collection('updates') _, summary, _ = sess.run([updates, merged_summaries, train_op]) 

in case, return value sess.run() list 3 elements, first (ignored) element list same length updates.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -