November 2018
Intermediate to advanced
322 pages
7h 54m
English
To enable the logging of variable placement by defining a config object, set the log_device_placement property to true, and then pass this config object to the session as follows:
tf.reset_default_graph()# Define model parametersw = tf.Variable([.3], tf.float32)b = tf.Variable([-.3], tf.float32)# Define model input and outputx = tf.placeholder(tf.float32)y = w * x + bconfig = tf.ConfigProto()config.log_device_placement=Truewith tf.Session(config=config) as tfs: # initialize and print the variable y tfs.run(global_variables_initializer()) print('output',tfs.run(y,{x:[1,2,3,4]}))
The output from the console window of the Jupyter Notebook is listed as follows:
b: (VariableV2): /job:localhost/replica:0/task:0/device:GPU:0 ...
Read now
Unlock full access