Fix logic error for calculating deltas, implement L2 regularization.

The logic error was guiding the deltas away from the optimal solutions,
resulting in tests that were doing worse than random (and in fact
getting close to a 100% error rate!).

The cost function was changed the simpler (and better) cross-entropy
function. This should result in less epochs needed to get to an optimal
solution.