Stochastic resonance as an emergent property of neural networks