A Unified Framework for Detecting Out-of-Distribution and Adversarial Samples