Biological credit assignment through dynamic inversion of feedforward networks