import numpy as np
import tensorflow as tf

#numpy
a = np.array([5,3,8])
b = np.array([3,-1,2])
c = np.add(a,b)
print('numpy data')
print(c)

#Tensorflow
#Build
a = tf.constant([5,3,8])
b = tf.constant([3,-1,2])
c = tf.add(a,b)
print(c)

#scalar
x = tf.constant(4)

#vector
x = tf.constant([3,5,7])

#matrix
#2D
x = tf.constant([[3,5,7],[4,6,8]])
#Get 0th column
y = x[:,0]

#Get the 0th row
z = x[0,:]

#get two values only
#start at 0, fetch two elements
#python range first number included last number is not
zz = x[0,:2]

#rewrite into 3x2 rows
yy = tf.reshape(x,[3,2])

#rewrite into 6x1 rows
yyy = tf.reshape(x,[6,1])

#3D
x = tf.constant([[[3,5,7],[4,6,8]]])

#placeholders to feed value
data = tf.placeholder("float",None)
b = data*2

#Run
with tf.Session() as sess:
  result = sess.run(c)
  print('tensor data')
  print(result)
  print('c evaluation')
  print(c.eval())
  print(y.eval())
  print(z.eval())
  print(zz.eval())
  print(yy.eval())
  print(yyy.eval())
  print(sess.run(b,feed_dict={data: [1,2,3]}))