A random energy approach to deep learning