python


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.

Related Links

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

Categories

HOME
app-inventor
elixir
angular-cli
textwatcher
webrtc
facebook-graph-api
thunderbird-addon
wampserver
flyway
azureservicebus
gspread
tumblr
sequelize.js
eclipse-cdt
ndis
android-source
lagom
future
jacoco
eclipse-luna
jquery-terminal
scenebuilder
zend-framework-mvc
nmake
google-ima
jquery-form-validator
onsen-ui
qsub
continuous-deployment
ui5
emv
image-quality
web-frontend
bitcoin-testnet
svnkit
spring-insight
m2e
polymorphism
geopy
viewstate
bing-maps-api
vsts-package-management
deepstream.io
delphi-10.1-berlin
brute-force
react-native-router-flux
productivity
crop
matlab-cvst
z3py
crystal-reports-8.5
android-bitmap
nuget-server
onresume
svn-merge
gradle-script-kotlin
iostat
windows-nt
gradle-eclipse
kendo-combobox
amazon-kcl
mfc-feature-pack
asynccallback
axes
spservices
unity5.3
paypal-nvp
leadtools-sdk
rx-groovy
twitter-rest-api
httpie
virus
google-earth-plugin
android-search
python-ggplot
qtestlib
formvalidation-plugin
emma
picat
config-files
initialization-vector
resource-files
logentries
nsmatrix
asp.net-mvc-scaffolding
dig
client-library
vertical-scrolling
moq-3
isolatedstorage
hobo
coff
authenticode
audiostreamer
zend-form-element
out-of-browser
unreachable-code
camtasia
aio
mvvm-foundation
evb

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App