Finding the max error of a set of training data
Current approach
Right now, you train on randomly selected inputs from the set of all possible inputs and keep track of the highest error per input using a map.  There are a couple of things I don't like about this:

By randomly selecting inputs, you might fail to cover all inputs.  Then you might think the net is finished training when it actually might fail to handle an input that was never randomly picked.
Keeping track of the highest error per input is slow.

New approach - training in rounds
I suggest changing your approach in the following way:

When you train, you must train in &quot;rounds&quot;.
At the beginning of each round, you shuffle the order of the possible inputs.
One round consists of training on each input one by one in the shuffled order.
During training, the highest error is tracked for the round.  This is now just a single variable instead of a map.
At the end of each round, training either stops if the highest error is good enough, or continues to the next round if the error is too high.