Resource-Constrained On-Device Learning by Dynamic Averaging