Efficient learning in spiking models