Posts

Matrix Subtract like Matrix Multiplication in tensorflow

Image
1 This is my first post I usually found all my answers in the archives, but having a hard time with this one, thanks for the help! I have two matrix A and B. Performing a matrix multiplication operation is trivial using tf.matmult. But I want to do matrix subtract similar to how matrix multiplication works. Eg if I have. A = tf.constant([[1, 1, 1, 2, 3, 1],[1,2,3,4,5,6],[4,3,2,1,6,5]]) B = tf.constant([[1,3,1],[2,1,1]]) #B*A X = tf.matmult(B,A) >>>X = [[8,10,12,15,24,24],[7,7,7,9,17,13]] What I want to do is do a similar operation like matmult, but instead of multiply I want subtract and square. Eg... for x 11 , where the subscript 11 is row 1, column 1 of matrix X. = (-b 11 + a 11 ) 2 + (-b 12 + a 21 ) 2 + (-b 13 + a 31 ) 2 and x 12 = (-b 11 + a 12 ) 2 + (-b 12 + a 22 ) 2 + (-b 1...