A deep learning approach to solving inverse problems