个人理解 :操作就是方法
日常附代码
import tensorflow as tf
a = tf.constant(2)
b = tf.constant(3)
with tf.Session() as sess:
print("a: %i:" % sess.run(a))
print("b: %i:" % sess.run(b))
print("Addition with constants : %i " % sess.run(a + b))
print("Multiplication with constants : %i " % sess.run ( a * b))
a: 2:
b: 3:
Addition with constants : 5
Multiplication with constants : 6
x = tf.placeholder( tf.int16 , shape= () , name = "x")
y = tf.placeholder( tf.int16 , shape= () , name = "y")
add = tf.add(x, y)
mul = tf.multiply(x, y)
with tf.Session() as sess:
print("Addition with constants : %i" % sess.run (add , feed_dict = { x : 10 , y : 3}) )
print("Multiplication with constants : %i " % sess.run (mul , feed_dict = { x : 3 , y : 7}))
Addition with constants : 13
Multiplication with constants : 21
展开