In this paper we introduce the textsc{Deepz} deep learning photometric redshift (photo-$z$) code. As a test case, we apply the code to the PAU survey (PAUS) data in the COSMOS field. textsc{Deepz} reduces the $sigma_{68}$ scatter statistic by 50% at $i_{rm AB}=22.5$ compared to existing algorithms. This improvement is achieved through various methods, including transfer learning from simulations where the training set consists of simulations as well as observations, which reduces the need for training data. The redshift probability distribution is estimated with a mixture density network (MDN), which produces accurate redshift distributions. Our code includes an autoencoder to reduce noise and extract features from the galaxy SEDs. It also benefits from combining multiple networks, which lowers the photo-$z$ scatter by 10 percent. Furthermore, training with randomly constructed coadded fluxes adds information about individual exposures, reducing the impact of photometric outliers. In addition to opening up the route for higher redshift precision with narrow bands, these machine learning techniques can also be valuable for broad-band surveys.