Compressing CNN models for resource-constrained systems by channel and layer pruning