Training spiking neural networks end-to-end with surrogate gradients