A Learnable Safety Measure