In [2]:
import tensorflow as tf
In [ ]:
#(a-b)^2=a^2+b^2-2ab
#let conder the values
a=4
b=8
with tf.name_scope("ML_Assignment1"):
with tf.name_scope("A"):
w = tf.multiply(a,a)
x = tf.multiply(b,b)
with tf.name_scope("B"):
y = tf.multiply(2,a)
z = tf.multiply(y,b)
with tf.name_scope("C"):
r1 = tf.add(w,x)
res = tf.subtract(r1,z)
with tf.Session() as sess:
writer = tf.summary.FileWriter("/tmp/tboard/output3_NEHA1",sess.graph)
print(sess.run(res))
writer.close()
In [ ]:
In [ ]:
In [ ]:
In [3]:
#(a-b-c)^2=a^2+b^2+c^2-2ab-2bc-2ca
#let conder the values
a=4
b=5
c=10
with tf.name_scope("ML_Assignment2"):
with tf.name_scope("A"):
r = tf.multiply(a,a)
s = tf.multiply(b,b)
t = tf.multiply(c,c)
with tf.name_scope("B"):
u1 = tf.multiply(2,a)
res1 = tf.multiply(u1,b)
with tf.name_scope("C"):
u2 = tf.multiply(2,b)
res2 = tf.multiply(u2,c)
with tf.name_scope("D"):
u3 = tf.multiply(2,c)
res3 = tf.multiply(u3,a)
with tf.name_scope("E"):
r1 = tf.add(r,s)
r2 = tf.add(r1,t)
final1= tf.subtract(r2,res1)
final2= tf.subtract(final1,res2)
finalresult= tf.add(final2,res3)
with tf.Session() as sess:
writer = tf.summary.FileWriter("/tmp/tboard/output3_NEHA2",sess.graph)
print(sess.run(finalresult))
writer.close()
In [ ]: