I am trying to multiply a set of vectors with corresponding matrices and would like to sum the resulting vectors at the end. As a numpy example let's assume we have 20 vectors and matrices of sizes 10x1 and and 150x1 respectively:
import numpy as np
np_b=[ np.random.rand(10) for i in range(20)]
np_A=[ np.random.rand(150,10) for i in range(20)]
#first we multiply each vector with it's corresponding matrix
np_allMuls=np.array([np.dot(np_A[i],np_b[i]) for i in range(20)] )
#then we sum all of the vectors to get the 150 dimensional sum vector
np_allSum=np.sum( np_allMuls,axis=0 )
So far with tensorflow 0.10 I got:
import tensorflow as tf
tf_b = tf.placeholder("float", [None,10])
tf_A= tf.placeholder("float", [None,150,10])
#the following gives me ValueError: Shape (?, 150, 10) must have rank 2
tf_allMuls=tf.matmul(tf_A,tf_b)
But this symbolic multiplication gives me the error "ValueError: Shape (?, 150, 10) must have rank 2".
Does anyone know why I am getting such an error message? How can I get tf_allMuls correctly?