TRIM: A Design Space Exploration Model for Deep Neural Networks Inference and Training Accelerators