In [ ]:


In [2]:
#USN:01fe15bcs237
#Assignment_1
#Roll244
#(a-b)^2
import tensorflow as tf


with tf.name_scope("A_minus_B_sqare"):
    a = tf.placeholder(tf.float32)
    b = tf.placeholder(tf.float32)
    with tf.name_scope("Power_Operation"):
        a2 = tf.pow(a,2, name="a_pow")
        b2 = tf.pow(b,2, name="b_pow")
    with tf.name_scope("Multiplication_Operation"):
        ab = tf.multiply(a, b,name="ab")
        ab2=tf.multiply(ab, 2,name="2ab")
    with tf.name_scope("Scope_subraction"):
        c=tf.subtract(a2,ab2,name="a2-2ab")
        d=tf.add(c,b2,name="a2_minus_2ab_plus_b2")

with tf.Session() as sess:
    writer = tf.summary.FileWriter("/tmp/tboards/outputy", sess.graph)
    print(sess.run( d ,{a:4,b:2}))
    writer.close()
    
    #tensorboard --logdir=/tmp/tboards/outputy


4.0

In [1]:
#USN:01fe15bcs237
#Assignment_1
#Roll244
#(a+b)^3
import tensorflow as tf

with tf.name_scope("Answer"):
    a = tf.placeholder(tf.float32)
    b = tf.placeholder(tf.float32)
    a3 = tf.pow(a,3, name="a_pow")
    b3 = tf.pow(b,3, name="b_pow")
    ab = tf.multiply(a, b,name="ab")
    ab3=tf.multiply(ab, 3,name="_3ab")
    a_plus_b=tf.add(a,b)
    d=tf.multiply( a_plus_b, ab3,name="_3ab_mult_aplusb")
    e=tf.add(a3,b3,name="a3_plus_b3")
    f=tf.add(e,d,name="a_plus_b_cube")
        

with tf.Session() as sess:
    writer = tf.summary.FileWriter("/tmp/tboard/output_", sess.graph)
    print(sess.run( f ,{a:4,b:2}))
    writer.close()
    
    #tensorboard --logdir=/tmp/tboard/output_


216.0

In [ ]:


In [ ]: