Learning to Cope with Adversarial Attacks