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))
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))
In [12]:
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))
In [8]:
In [ ]: