Capturing Shock Waves by Relaxation Neural Networks