#!/usr/bin/env python # coding: utf-8 # In[1]: import tensorflow as tf # In[7]: # Fetch a = tf.constant(1.0) b = tf.constant(2.0) c = tf.constant(3.0) multiply = tf.multiply(a, b) add = tf.add(matmul, c) # Fetch可以运行多个 Op with tf.Session() as sess: print(sess.run([add, multiply])) # In[8]: # Feed ph1 = tf.placeholder(tf.float32) ph2 = tf.placeholder(tf.float32) m = tf.multiply(ph1, ph2) # 在真正执行的时候,再将数据以字典的形式传入 with tf.Session() as sess: print(sess.run(m, feed_dict={ph1: [1.0], ph2: [2.0]}))