The performance improved in calculating the cost and the gradient. It was observed on dense data, didn't try it on sparse yet.

It might look peculiar, but it has something to do with the matrix multiplications. I just played with the <code>timeit</code> library to understand the performance increase. I found that if for example you multiply matrices A and B, together, while assuming the time it takes is 0.25 ms for such multiplication, then multiplying B.T with A.T could take twice as longer, that is 0.5 ms. So, that small time increase will add up if the cost and gradient is calculated multiple times.

I will commit the non-transposed function to benchmark again, just to be safe.