finished gradient checking for L (todo: clean up code, add regularization gradients and SGD