I have a Tensor A with the shape: [1000,24,24,2] and I want to multiply it with its transpose so that I can get C = A^T.A
I tried:
B=tf.transpose(A)
C = tf.matmul(B, A)
and I get this error:
InvalidArgumentError: {{function_node _wrapped__BatchMatMulV2_device/job:localhost/replica:0/task:0/device:CPU:0}} In[0] and In[1] must have compatible batch dimensions: [2,24,24,1000] vs. [1000,24,24,2] [Op:BatchMatMulV2]
How can I do this in Tensorflow?
Probably you are wondering about elementwise matrix product keeping to the first (1000) and the last (2) dimensions. The matrix product is likely expected with respect to one of the 24 dimesions. This case I suggest
tf.matmulI replaced one dimension from 24 by 25 in order to make it clear which of the dimensions is convoluted.