Sam Harris has a good explanation of rules to live by if attacked:
The primary goal of self-defense is to avoid becoming the victim of violence. The best way to do this is to not be where violence is likely to occur. Of course, that’s not always possible—but without question, it is your first and best line of defense. If you visit dangerous neighborhoods at night, or hike alone and unarmed on trails near a big city, or frequent places where drunken young men gather, you are running some obvious risks.
Whatever your training, you should view any invitation to violence as an opportunity to die—or to be sent to prison for killing another human being. Violence must truly be the last resort. Thus, if someone sticks a gun in your face and demands your wallet, you should hand it over without hesitation—and run.
This is the core principle of self-defense: Do whatever you can to avoid a physical confrontation, but the moment avoidance fails, attack explosively for the purposes of escape—not to mete out justice, or to teach a bully a lesson, or to apprehend a criminal. Your goal is to get away with minimum trauma (to you), while harming your attacker in any way that seems necessary to ensure your escape.
I've started Krav Maga training mainly to get in shape—but also because Krav Maga teaches the same principles.