import tensorflow as tf
sess = tf.Session()
import numpy as np
myarray = np.array([[1.,3.,5.,7.,9],[-2.,0.,2.,4.,6],[-6.,-3.,0.,3.,6]])
myarray
array([[ 1., 3., 5., 7., 9.],
[-2., 0., 2., 4., 6.],
[-6., -3., 0., 3., 6.]])
x_vals = np.array([myarray,myarray+1])
x_vals
array([[[ 1., 3., 5., 7., 9.],
[-2., 0., 2., 4., 6.],
[-6., -3., 0., 3., 6.]],
[[ 2., 4., 6., 8., 10.],
[-1., 1., 3., 5., 7.],
[-5., -2., 1., 4., 7.]]])
x = tf.placeholder(tf.float32,shape=(3,5))
m1 = tf.constant([[1.],[0.],[-1.],[2.],[4.]])
m2 = tf.constant([[2.]])
a1 = tf.constant([[10.]])
prod1 = tf.matmul(x,m1)
prod2 = tf.matmul(prod1,m2)
add1 = tf.add(prod2,a1)
for x_val in x_vals:
print(sess.run(add1,feed_dict={x:x_val}))
[[102.]
[ 66.]
[ 58.]]
[[114.]
[ 78.]
[ 70.]]