NN training fixes

Few bugs here and there that caused training not to work. Also, I did
the training process wrong, so I fixed that. Now trains over all of the
patterns per epoch.