import tensorflow as tf
with tf.device('/gpu:0'):
foo = tf.Variable(1, name='foo')
assert foo.name == "foo:0"
with tf.device('/gpu:1'):
bar = tf.Variable(1, name='bar')
assert bar.name == "bar:0"
Run Code Online (Sandbox Code Playgroud)
上面的代码返回true.我with tf.device在这里用来说明":0"并不意味着变量位于特定的设备上.那么变量名称中":0"的含义是什么(本例中为foo和bar) )?