The accurate prediction of rainfall, and in particular rainfall extremes, remains challenging for numerical weather prediction models. This can be attributed to subgrid-scale parameterizations of processes that play a crucial role in the multi-scale dynamics, as well as the strongly intermittent nature and the highly skewed, non-Gaussian distribution of rainfall. Here we show that a specific type of deep neural networks can learn rainfall extremes from a numerical weather prediction ensemble. A frequency-based weighting of the loss function is proposed to enable the learning of extreme values in the distributions' tails. We apply our framework in a post-processing step to correct for errors in the model-predicted rainfall. Our method yields a much more accurate representation of relative rainfall frequencies and improves the forecast skill of extremes by factors ranging from two to above six, depending on the event magnitude.