如果什么都不加,直接运行装了GPU的Tensorflow,结果是这样子的 import tensorflow as tf a = tf.constant([1.0, 2.0, 3.0], shape=[3], name='a') b = tf.constant([1.0, 2.0, 3.0], shape=[3], name='b') c = a + b sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) # 通…
先感受一下队列之美 import tensorflow as tf q = tf.FIFOQueue(2, "int32") # 创建一个先进先出队列 # 队列中最多可以保存两个元素,并指定类型为整数 init = q.enqueue_many(([0, 10],)) x = q.dequeue() y = x + 1 q_inc = q.enqueue([y]) with tf.Session() as sess: init.run() for _ in range(5): v, _…
1.运行以下代码 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() 得到 其中,add与代码中的add有关,0表示第一个输出,图中的…