Design Space Exploration And Architecture Design For Inference And Training Deep Neural Networks