Understanding and Improving Reliability of Predictive and Generative Deep Learning Models