Many forms of learning, for example, learning a model of the environment or a motor skill, rely on synaptic plasticity that is widely distributed across cell types and network stages. Understanding how this distributed plasticity functions is a central challenge in neuroscience1-5. Here we use connectomics to map the cell types and synaptic connections underlying a form of multi-layer continual learning that cancels predictable sensory responses in a cerebellum-like structure in electric fish6,7. Our analysis shows inhibitory and disinhibitory sensory input pathways that fulfil theoretical requirements for instructing synaptic plasticity8,9, structured synaptic connectivity between network stages that solves a credit assignment problem and structured recurrent connectivity that accelerates sensory prediction and cancellation. A computational model constrained by electrophysiological recordings shows how this synaptic connectivity ensures that multiple sites of plasticity cooperate to overcome their individual limitations, resulting in cancellation that is fast, accurate and robust to noise. Overall, these findings highlight the potential of connectomics, in combination with cell-type-specific physiological recordings and computational modelling, for deciphering learning in neural circuits.