Efficient methods and hardware for deep learning