I have 2 3D-tensors A of shape (batch_size, dim1, dim2) and B of size (batch_size, dim2, dim3). I would like to perform the following computation:
C = np.zeros((batch_size, dim1, dim3))
for i in range(batch_size):
c[i] = A[i].dot(B[i])
I tried C = tf.matmul(A,B)
, but got the error:
tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 2 but is rank 3 for 'MatMul' (op: 'MatMul') with input shapes: [10,100,100], [10,100]
Is there any efficient way to implement this in TensorFlow? Thank you!