def reshape_matmul(mat): v1 = tf.expand_dims(mat, 1) v2 = tf.reshape(v1, [3, batch_size, 1]) return(tf.batch_matmul(v2, v1)) # Compute SVM Model