Tensorflow amount of detail and the use of the concept of -P42 Zhang

1, run the following code

import tensorflow as tf
a = tf.constant([1.0, 2.0], name="a")
b = tf.constant([2.0, 3.0], name="b")
result = a + b
print result

sess = tf.InteractiveSession ()
print(result.eval())
sess.close()

Obtained
image.png
wherein, add the code related to add, 0 represents the first output, in FIG Shape (2,) indicates a length of 2 one-dimensional array

2, talk about a particularly important concept --result.get_shape () can be obtained tensor dimension information

3, see result.eval (session = sess) Do not be surprised, sess = tf.Interactivesession () is also not surprising, even if the other

4, as

g=tf.Graph()
with g.device('/gpu:0'):
  result = a+b

This concept not talk about it

Guess you like

Origin www.cnblogs.com/liuboblog/p/11615641.html