A foolproof way to shrink deep learning models