In [2]:
import tensorflow as tf
import numpy as np

In [7]:
x = [1,2,3]
y = tf.Variable(x)
sqx = tf.square(x)
sqy = tf.square(y)


with tf.Session() as sess:
    sess.run(tf.initialize_all_variables())
    print(sess.run(sqx))
    print(sess.run(sqy))


[1 4 9]
[1 4 9]

In [6]:
x = tf.constant([[1,2,3],[4,5,6],[7,8,9]])
rdc_sum = tf.reduce_sum(x)# reduction_indices = 0)

with tf.Session() as  sess:
    print(sess.run(rdc_sum))


45

In [11]:
y = tf.constant([[1,2,3],[5,6,7],[9,10,11]])
nrm = (x-y)**2

rdc_nrm1 = tf.reduce_sum(nrm,reduction_indices = 1)

with tf.Session() as sess:
    print(sess.run(nrm))
    print(sess.run(rdc_nrm1))


[[0 0 0]
 [1 1 1]
 [4 4 4]]
[5 5 5]

In [8]:



Tensor("pow:0", shape=(3, 3), dtype=int32)

In [ ]: