I started to study tensor flow and am having difficulty understanding problems with placeholders / variables.
I am trying to write a function for matrix multiplication. It works when using tf.constant, but it's hard for me to figure out how to use variables
here is my code
import tensorflow as tf import numpy as np mat_1 = np.array([[0,1,1,0], [1,0,1,0], [1,0,0,1], [0,1,1,0]]).astype('int32') mat_2 = np.array([[0,1,1,0], [1,0,1,0], [1,0,0,1], [0,1,1,0]]).astype('int32') def my_matmult1(mat_1, mat_2):
This works as expected:
my_matmult1(mat_1, mat_1)
However, the following fails:
my_matmult2(mat_1, mat_1)
with the following error
InvalidArgumentError
You must submit a value for the 'Placeholder' placeholder with dtype int32 and form [4,4]
Even after changing the last line in
qq1 = x_sess1.run(r1, feed_dic={tf.convert_to_tensor(mat_1), tf.convert_to_tensor(mat_2)})
What am I doing wrong?