Faster training algorithm by transposing the matrices