import tensorflow as tf # Define a placeholder that expects a vector of three floating-point values # and a computation that depends on it x = tf.placeholder(tf.float32, shape=[3]) y = tf.square(x) with tf.Session() as sess: # Feeding a value changes…
一.即时执行模式 import tensorflow as tfimport tensorflow.contrib.eager as tfetfe.enable_eager_execution() a = tf.constant(12)counter = 0while not tf.equal(a, 1): if tf.equal(a % 2, 0): a = a / 2 else: a = 3 * a + 1 print(a) 二.用Eager执行模式的MNIST模型构建 import ten…
''' Created on May 24, 2017 @author: p0079482 ''' #使用程序输出日志 import tensorflow as tf with tf.Session() as sess: tf.initialize_all_variables().run() for i in range(TRAINING_STEPS): xs,ys=mnist.train.next_batch(BATCH_SIZE) #每1000轮记录一次运行状态 if i%1000==0:…