Catch math owerflow exception in neural_networks.py