How to solve XNOR problem with neural network?
Combine a NN for x1 AND x2 [your a1] with a NN for (NOT x1) AND (NOT x2) [your a2] to get the XNOR. You end up with inputs +1, x1, and x2 going to your hidden neurons a1 and a2, then +1, a1, and a2 into your output neuron.