Is Session.run(fetches) guaranteed to execute its “fetches” arguments in-order?
Is Session.run(fetches, feed_dict) guaranteed to execute its fetches arguments in-order? The documentation doesn't seem to mention it. For example, if you run sess.run([accuracy, train_op], feed_dict=feed_dict) the order of execution matters: train_op will update parameters affecting accuracy.
No. By default, Tensorflow is free to evaluate operators in any order. Because of concurrency, that order may even change between runs. This is usually a good thing because it means that Tensorflow may make optimal use of the available hardware. It can be problematic if your code mutates state such as Variables. However, if for some reason you do wish to control the order of evaluation, in general you can use control dependencies to enforce an order between operators. Control dependencies are documented here: https://www.tensorflow.org/api_docs/python/tf/Graph#control_dependencies Hope that helps!
After posting this, and during the discussion in Is it possible to get the objective function value during each training step? I noticed that the execution order is undefined. For example, consider this code: import tensorflow as tf x = tf.Variable(0, dtype=tf.float32) loss = tf.nn.l2_loss(x-1) train_opt = tf.train.GradientDescentOptimizer(1) train_op = train_opt.minimize(loss) init_op = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init_op) print sess.run([x, train_op]) With TensorFlow 1.1, if the environment variable CUDA_VISIBLE_DEVICES is set to one of the GPUs, this prints [0.0, None] and if it is set to "", this code prints [1.0, None] Unfortunately, I don't see anything in the documentation specifying the execution order or warning users that it's undefined.
Kivy Widget does not accepts properties and commands
Efficient combinations of combinations
what metric should I monitor for a spider in scrapy
Why is Aptana/Pydev showing “undefined variable” errors for “print” and “__name__” in my helloworld python code?
Python Tkinter: Delete label not working
How to call a function after adding values to an Option Menu?
using python to verify that a shapefile is a shapefile (fiona, ogr)
Identifying largest connected component in a matrix
VBA shell script set environment variable before execution
Embed matplotlib in PyQt
Odoo - overriding old api method with new api?
Pylint warning - W5304(Missing-Test-Class)
In terms of efficiency/quickly rejecting things, does it matter if your if statements are on the same line?
QComboBox drop-down list adding unnecessary scroll bar
Specify color type for bar graph pylab
prettifying a part of the html doc using beautifulsoup