Safety-driven learning for perception and decision making in autonomous systems