Assignment 1

(a+b)2


In [11]:
import tensorflow as tf
a=tf.constant(5)
b=tf.constant(6)
c=tf.multiply(a,a)
d=tf.multiply(b,b)
e=tf.multiply(2,a)
f=tf.multiply(e,b)
g=tf.add(c,d)
h=tf.add(g,f)

with tf.Session() as sess:
    writer = tf.summary.FileWriter("/tmp/tboard/squareab", sess.graph)
    print(sess.run(h))
    writer.close()


121

(a+b+c)2


In [18]:
import tensorflow as tf
a=tf.constant(5)
b=tf.constant(6)
c=tf.constant(8)
d=tf.multiply(a,a)
e=tf.multiply(b,b)
f=tf.multiply(c,c)
g=tf.multiply(2,a)
h=tf.multiply(g,b)
i=tf.multiply(2,b)
j=tf.multiply(i,c)
k=tf.multiply(2,c)
l=tf.multiply(k,a)
m=tf.add(d,e)
n=tf.add(m,f)
o=tf.add(n,g)
p=tf.add(o,i)
q=tf.add(p,k)

with tf.Session() as sess:
    writer = tf.summary.FileWriter("/tmp/tboard/squareabc", sess.graph)
    print(sess.run(q))
    writer.close()


163

In [ ]: