Learning to Attack, Protect, and Enhance Deep Networks