Dendritic predictive coding: A theory of cortical computation with spiking neurons

Top-down feedback in cortex is critical for guiding sensory processing, which has prominently been formalized in the theory of hierarchical predictive coding (hPC). However, experimental evidence for error units, which are central to the theory, is inconclusive, and it remains unclear how hPC can be implemented with spiking neurons. To address this, we connect hPC to existing work on efficient coding in balanced networks with lateral inhibition, and predictive computation at apical dendrites. Together, this work points to an efficient implementation of hPC with spiking neurons, where prediction errors are computed not in separate units, but locally in dendritic compartments. The implied model shows a remarkable correspondence to experimentally observed cortical connectivity patterns, plasticity and dynamics, and at the same time can explain hallmarks of predictive processing, such as mismatch responses, in cortex. We thus propose dendritic predictive coding as one of the main organizational principles of cortex.


Introduction
A central feature of perception is that our internal expectations to a large degree shape how we perceive the world [1]. A long line of research aims to describe these expectation-guided computations in our brain by Bayesian inference, i.e. statistically optimal perception [2], and subsequently could show that Bayesian inference can capture perception extraordinarily well [1]. In light of this success, it has been proposed that the primary computation that is performed by the cortex is a hierarchically organized inference process, where cortical areas combine bottom-up sensory information and topdown expectations to find a consistent explanation of sensory data [3,4,5].
While the general idea of hierarchical inference in cortex found considerable experimental support [1,5], it is less clear how exactly this inference could be implemented by cortical neurons. A popular theory that has been proposed to describe the neural substrate of inference in cortex is classical hierarchical predictive coding (hPC) [4,6]. A central proposition of this theory is the existence of error units, which are thought to compare top-down predictions to bottom-up inputs, and guide neural computation and plasticity. However, classical hPC for the most part remains on the level of firingrate dynamics of neural populations, and it has proven difficult to connect the theory to the properties of single neurons with spiking dynamics [7,8].
With this perspective we point towards a different, emerging theory of biologically plausible hierarchical inference, which relies on the local membrane dynamics in neural dendrites. The core idea of this theory, which we will refer to as dendritic hPC, is to shift error computation from separate neural populations into the dendritic compartments of pyramidal cells. As we will discuss, this shift in per-spective for the first time enables a biologically plausible implementation of hPC with spiking neurons, and bears the potential to explain how cortical computations are organized from the micro-scale of individual dendrites to the macro-scale of cortical areas.
In the first part of the perspective, we will outline the theory of dendritic hPC and explain how it allows for inference with biologically plausible spiking dynamics and synaptic plasticity. In the process, our goal is to combine several theoretical insights that have been gained over the last years into a coherent picture of cortical computation. A central contribution of this section therefore is to point out the intimate relations that exist between three previously mostly independent branches of research of theoretical neuroscience: Hierarchical predictive coding [6], efficient coding in balanced spiking networks [9] and the theory of neural sampling in probabilistic models [10]. In the larger, second part, we will discuss the biological plausibility of the theory, and explain how several experimental observations of hierarchical cortical computation fit into the picture. Ultimately, we will discuss the open challenges and most interesting avenues of theoretical and empirical research that are opened up by this this new perspective.
2 Dendritic predictive coding in balanced spiking neural networks

Classical models of predictive coding
Hierarchical predictive coding (hPC) describes the processing of sensory information as inference in a hierarchical model of sensory data (see Infobox 4.1 for the basic notions of inference in generative models; see Infobox 2.1 for mathematical details, which are not needed to understand the main text). The central idea of hPC is that activity of prediction units in one level of the hierarchy i) should accurately predict sensory data, or the prediction unit activity in a lower level, and ii) should be consistent with top-down predictions generated by higher levels in the hierarchy.
hPC tries to understand how these properties of neural activity can be ensured by neural dynamics on short timescales, and neural learning and plasticity on long timescales. The theory predicts that to this end the prediction units in every level of the hierarchy need access to two types of errors: i) Bottom-up errors, i.e. the mismatch between predictions generated within the level and the activity in lower levels.
ii) Top-down errors, i.e. the mismatch between top-down predictions and the activity within the level.
A neural implementation thus also requires a neural substrate for these errors. In classical hPC [6], the key innovation was to represent these errors in distinct populations of error units that compare top-down predictions with the activity within a level ( Fig 1A). The elegance of this approach is that the same error units can mediate both, bottom-up errors to update prediction units in the next level, as well as top-down errors to neurons of the same level. Another central result of classical hPC is that the learning rules that improve the hierarchical model take the form [error × prediction], which in the proposed architecture turns out to be classic Hebbian plasticity, i.e. the multiplication of preand postsynaptic activity.  The errors that are computed in the dendritic membrane potentials are integrated at the soma to form an overall error signal of the neuron's encoding. A spike is emitted when the somatic error potential grows too large, and a spike would lead to a reduction in the overall error.

A functionally equivalent formulation of predictive coding with local dendritic error computation
Although the idea of error units is undeniably elegant, it is not the only way to compute prediction errors in a neural circuit. Mathematically equivalent, one may understand error computation as an operation that is performed in the voltage dynamics of individual dendritic compartments (see Infobox 2.1 for mathematical details)-and, thus, without specialized error units. In this reinterpretation of hPC every neuron will represent the two types of errors we discussed before in different sections of its dendritic tree ( Fig 1B): i) Bottom-up errors in basal dendritic compartments, where input from lower-level cortical areas is integrated [17].
ii) The top-down prediction error (for the neuron's own activity) in an apical compartment, where higher-level cortical feedback arrives [17].
Besides the absence of error neurons, two additional central differences arise between the architectures of classical hPC, and this dendritic hPC. First, in dendritic hPC both bottom-up and top-down signals are predictions. The possibility to implement hPC in such a manner (by redrawing hierarchicallevel boundaries) has previously been discussed by Spratling [18]. Second, and more importantly, while prediction units in classical hPC inhibit each other through error units, prediction neurons in dendritic hPC directly compete through lateral inhibition on basal dendrites. Such networks with strong lateral inhibition (or similarly, winner-take-all-like dynamics) have a long tradition in theoretical  [6] (for a detailed tutorial see [11]) where θ are the model parameters, r i is neural activity of a neural network at level i, and inputs are provided by the previous level r i−1 . This defines a hierarchy of processing stages that for example can be associated with different visual cortical areas (e.g. V1, V2, etc.), where r 0 are visual inputs from LGN [6]. Typically, a linear model is assumed, where inputs are modelled according to with decoding matrix D i and Gaussian white noise n i−1 with zero mean and variance σ 2 i−1 . With this model, for a single level i, the relevant contributions of the negative log-likelihood −L i take the intuitive form of the square sum of coding errors for bottom-up inputs and errors of topdown predictions: bottom-up error: The goal is then to minimize the sum of coding errors on a fast timescale τr via neural dynamics d dt r i , and with a slow learning rate ηD via neural plasticity on the weights D i , by performing gradient ascent on L: To yield a neural implementation, the key innovation in classical hPC was to represent prediction errors within a distinct neural population of error units, that integrate inputs of prediction units within the same level, and subtract top-down predictions according to where decoding weights D i now correspond directly to weights of neural connections [11]. Together with the dynamics of prediction units, this results in the hierarchical neural circuit shown in Fig 1A. Predictive coding with dendritic errors.
In dendritic hPC, the computation of errors in Eq (7) is accomplished by the leaky voltage dynamics of dendritic compartments [9,12,13].
To this end, for each prediction neuron j one introduces basal dendritic compartments b i jk ≈ D i kj e i−1 k , which are each innervated by a single synapse of a prediction neuron k of the previous level, as well as an apical compartment a i j ≈ −e i j that is innervated by prediction neurons of a higher level (Fig 1B). The error computation is then performed by voltage dynamics according to where bottom-up inputs are balanced with lateral connections W i jkl (connection of neuron r i l to the kth dendritic compartment of neuron r i j ), and topdown predictions are matched by the neurons own predictions r i j . The latter could be implemented via the backpropagating action potential [14], solving the one-to-one connections problem of classical hPC [15]. To compute bottom-up errors, lateral weights have to be chosen as W i jkl = D i kj D i lj . This can be achieved if lateral plasticity enforces a tight balance [13] The dynamics of prediction neurons are then simply driven by the dendritic error potentials and weights for bottom-up and top-down inputs can be learned with voltage-dependent rules Here, correct learning requires the cooperation of lateral and bottom-up weights, which in classical hPC is known as the weight transport problem [15,16]. For dendritic hPC this problem has so far been addressed in the single-level case [13]. Together, these equations yield an equivalent formulation of hPC for both, learning and inference, where prediction errors are computed in tightly balanced dendritic compartments.
neuroscience, as models for the sparse and efficient encoding of sensory data [13,19,20,21] and as divisive normalization models of cortical computation [22,23] (see also [24]). Dendritic hPC is closely related to these models with lateral inhibition, except that these models so far did not consider how exactly top-down connections could guide neural computations with predictions. In a more general context it has been proposed that top-down connections could provide these predictions by targeting apical dendrites [14,25,26] (a similar architecture has also been used to implement backprop in a cortical microcircuit [27], see Infobox 2.2 for a comparison). With dendritic hPC, we propose that these ideas of hierarchical predictive coding and lateral competition can be combined to form a consistent theory of cortical computation.
Since error computation in dendritic hPC takes place in the voltage dynamics of basal and apical dendritic compartments, in the model these local potentials play an important role for synaptic plasticity. For basal dendrites, dendritic hPC predicts that lateral connections between neurons should establish a tight balance locally, and thereby compute the errors for bottom-up inputs [13]. The intuitive explanation for this computation is that in a tightly balanced state, every input that can be predicted from other neurons is effectively canceled, and the remaining unpredictable input constitutes the prediction error [9]. These errors can then be exploited by another voltage-dependent rule for bottom-up connections, in order to find an optimal encoding of inputs [13]. This second rule is in general Hebbian, but strong local inhibition during a postsynaptic spike would signal an over-prediction of a specific input, which consequently should lead to the local depression of bottom-up synapses. For apical dendrites it has been proposed that the error computation relies on the back-propagating action potential [14].
In this theory of apical learning, plasticity of top-down connections is Hebbian as well, but should be depressing for a depolarization of the apical dendritic potential in the absence of postsynaptic activity. By employing these voltage-dependent plasticity rules, dendritic hPC implements the same learning algorithm as classical hPC, but in prediction neurons with dendritic error computation (Infobox 2.1).

Dendritic errors enable an efficient implementation of hierarchical predictive coding with spiking neurons
Dendritic errors do not only yield an equivalent formulation of hierarchical predictive coding, they also enable inference with spiking neurons. Here, the inferred variables have to be efficiently represented by spikes, which is possible if spikes are only fired if they reduce the overall prediction error [9,12,31,32] (see Infobox 2.3 for the mathematical details of dendritic hPC with spiking neurons). As we elaborated above, this prediction error can be computed by dendritic and somatic voltage dynamics if lateral (inhibitory) connections enforce a tight balance between excitatory and inhibitory currents [9], where predictions track bottom-up input on fast timescales. In this case, an efficient spike encoding can be found with a simple threshold mechanism on the membrane potential that generates a spike when the error potential grows too large [12], similar to the generation of action potentials in biological neurons ( Fig 1C). Predictive coding thus serves a dual purpose here, by enabling both inference in a hierarchical model, and an efficient spike encoding of dynamical variables.
A central role in this inference scheme with spikes is played by noise in the neural dynamics, for two reasons. First, noise enables an efficient spiking code in the face of transmission delays. With deterministic neurons, even a small delay of inhibition can lead to erratic network behavior, since inhibition will often arrive too late to prevent synchronous spiking of large parts of a population [33]. Noise relaxes this constraint on the speed of feedback, since it effectively decouples and desynchronizes neural spiking [31,33,34]. Second, noise in spiking neural networks enables neural sampling [10,35,36]. Here, the idea is that neural activity samples possible predictions according to their likelihood, instead of computing a single best estimate as in classical hPC (Infobox 2.3). Neural sampling therefore is a principled way to represent uncertainty in inference via neural activity, and has for example been used to explain variability in neural responses [37], and the origin of multistability in perception [38]. Recent models show that neural sampling and efficient spike coding with tight excitation-inhibition

Infobox 2.2: Relation to dendritic microcircuits for error backpropagation
Closely related to dendritic hPC, recent work has explored the role dendrites could play in hierarchical computation and learning in cortex [27,28,29]. Most relevant, Sacramento et al. have proposed that a predictive coding-like dendritic microcircuit can implement the backpropagation algorithm [27]. While sharing many concepts, dendritic hPC and the dendritic error model by Sacramento et al. pursue different goals, which ultimately lead to different architectures ( Fig A).
The prime difference is that in dendritic hPC neurons compute prediction errors via a balance on basal dendrites, while in [27] neurons compute errors of the network's output to a target via a balance on apical dendrites. In support of the dendritic hPC model, the interneuron architecture in cortex is well adapted to provide fast lateral inhibition to basal dendrites, to rapidly compute prediction errors online during sensory processing; apical inhibition in comparison is rather slow, meaning that apical error computation would require a slow equilibration process (interneurons are discussed more in-depth in section 3.2). Furthermore, recent experimental observations seem to be at odds with the idea that a balance of inputs computes an error at apical dendrites, and are more consistent with a predictive role of apical activity [26,30]. However, these particular results of course do not rule out that cortical networks could make use of both proposed mechanisms in different modes of operation or different neural populations, e.g. depending on the task at hand.  [27] the goal is to generate a target output at the highest level (e.g. a label). To this end an 'inverted' model of hPC is employed [29], where inhibition at the apical dendrite is used to compute the backpropagated error of the output.
balance can be combined in a single model with dendritic error computation [13,35,36], relating these concepts to the proposed model of dendritic hPC (Infobox 2.3).
In addition to neural inference, dendritic errors also enable learning in populations of spiking neurons. This is not straightforward, since the switch from rate-based to spike-based models typically requires a modification of the learning algorithms. For example, when using populations of spiking error units as in classical hPC, prediction errors will have to be approximated by discrete events of spikes, and further approximations are necessary to represent both positive and negative values with spikes or non-negative firing rates [16]. To resolve this, it was proposed that errors are represented by deviations relative to a baseline firing rate [16], but this would require high firing rates and therefore seems implausible considering the low firing rates in neocortex [39]. An alternative is to represent positive and negative errors in separate populations [6,39], but it is unclear how in this case biological plasticity can recombine the positive and negative parts, which are both required for the learning of single synapses. Due to these difficulties, to the best of our knowledge, as of yet no complete implementation of hPC has been proposed that uses spiking error units (see also [8] for a recent and extensive review). In contrast, in dendritic hPC the same learning algorithm as for rate-based units can be straightforwardly applied to spiking neurons. The reason is that dendritic membrane potentials remain continuous quantities that can attain positive and negative values relative to some reference value, despite the spiking nature of neural responses. Therefore, these dendritic potentials can easily represent the prediction errors that are required for the learning of bottom-up and top-down connections (Infobox 2.1), which has been successfully applied in [13,14].

Infobox 2.3: Mathematical details of dendritic predictive coding with spikes
Spike-based predictions of sensory data.
In spiking neural networks, predictions are not based on scalar firing rates that attain some steady-state, but are dynamic quantities that change with each event of a spike. A popular choice to mathematically formalize the prediction generated by a spike at time tsp is via spike traces κ(t, tsp) = exp(−(t − tsp)/τ ) that decay exponentially with some time constant τ [12,13]. Predictions of a neuron j on level i then change upon a spike according to r i j (t) → r i j (t) + κ(t, tsp). This approximately corresponds to the way spikes are integrated in the membranes of postsynaptic neurons, and is in line with the intuition that spikes are more predictive for inputs close to spike time than for inputs further in the future. With these predictions r i j (t), the same formalism as before can be used to compute the instantaneous loglikelihood (Infobox 2.1): However, inference can no longer be implemented by simple gradient descent. Because spikes are predicting future data, finding an efficient spiking implementation of predictive coding becomes itself a predictive coding problem.
Efficient spiking implementation of predictive coding with dendritic errors.
One straightforward approach to implement inference with spikes is to deterministically fire a spike at time t if it instantly improves bottom-up and top-down errors, i.e. the log-likelihood L(t) [12]: This can be seen as a discrete implementation of gradient ascent to find the maximum a posteriori (MAP) estimate for predictions r i j . The resulting spike code can be considered efficient, since a spike is only fired if it contributes to improving the likelihood, otherwise neurons stay silent. As it turns out, this algorithm can be implemented by a simple spiking threshold mechanism together with the principle of tight balance [12], where a neuron fires a spike if its membrane potential u i j (t) surpasses a firing threshold Tj , i.e.
Here, b i jk (t) are the balanced dendritic potentials of basal dendrites and a i j (t) the potential of the apical dendrite as in Infobox 2.1, which represent bottom-up or top-down errors, respectively (Fig A). The somatic membrane potential u i j (t) thus represents a projection of the total error, enabling neurons to efficiently maximize the model likelihood (Fig 1C). Predictive coding with neural sampling.
Instead of finding an instantaneous MAP estimate, a more general approach to inference with spikes is to sample a collection of (binary) spikes S0..T = {s(t)|t ∈ {0..T }} from the posterior distribution of the generative model S0..T ∼ p θ (S0..T |r 0 0..T ) [13,40]. A central problem of this approach is that this distribution cannot be computed at any time t, since information about future inputs is missing and computing the normalization of the distribution is intractable [13,40]. Yet, using simple approximations, one can show that approximate sampling can be implemented with the same membrane potentials u i j (t) and threshold Tj as before (up to a constant factor), and a soft spiking threshold mechanism where sig(x) = 1/(1+exp(−x)) is the logistic function [13,35]. This model is a special case of the spike response model with escape noise [41], and can be implemented by a standard leaky integrate and fire neuron with a noisy membrane potential. Equations (11), (16) and (17) highlight the intimate relation that exists between the theories of hPC, efficient coding with spikes and neural sampling.

Is dendritic predictive coding biologically plausible?
In the previous section we have introduced the two main assumptions of dendritic hPC, which are that i) cortex implements inference in a hierarchical probabilistic model, and ii) errors of the resulting predictions are computed in the local voltage dynamics of basal and apical dendrites. The implications of the first assumption have been discussed at length in the context of classical hPC, and were found to align well with experimental observations [5,42,43]. From the second assumption, and the combination of the two assumptions, additional requirements on neural lateral connectivity and plasticity arise, which we will discuss in the following. As we will see, these requirements are remarkably in line with properties of cortical pyramidal neurons and inhibitory connectivity in cortex, which renders dendritic hPC a promising theory to explain their functions in cortical computations.

Dendritic error computation and synaptic plasticity in pyramidal neurons
To compute errors in basal dendrites, a tight and local excitation-inhibition (E-I) balance is required. That excitatory and inhibitory currents are balanced in cortical neurons is a well-established result [9], and it has been found in several instances that inhibition and excitation are tightly correlated, with inhibition trailing excitation by few milliseconds [9,44,45]. This tight balance leaves neurons only with a brief window of opportunity for spiking, which effectively decorrelates neural responses to inputs and thereby ensures an efficient neural code [46]. A tight E-I balance can therefore explain the origin of the irregular spiking patterns of neurons that have been observed throughout cortex [9]. Although models with a tight balance can reproduce irregular firing on the single neuron level, incorporating realistic synaptic transmission delays in these models can lead to oscillations on the population level [31]. Oscillations in cortical activity (especially in the Gamma frequency band that dominates in layer 2/3 [4]) have therefore been discussed as signatures of efficient coding in balanced networks [34] (see also [36]). Thus, a tight E-I balance as assumed by dendritic hPC is not only observed experimentally at the neuron level, but also reproduces more global firing statistics of cortical activity.
Consistent with dendritic hPC, this balance has later been found to also extend to individual neural dendrites [47,48,49]. Crucially, this local balance can be observed down to the scale of (at least) single dendritic branches [47], since the attenuation of dendritic currents prevents that inhibitory postsynaptic potentials spread into other dendritic compartments and influence the E/I balance there [50,51]. Experiments could also show that this local balance is maintained through localized synaptic plasticity, which reestablishes the balance after a perturbation, and coordinates excitatory and inhibitory plasticity locally [30,47,52,53,54,55]. Overall, these findings are compatible with the idea that a local balance computes prediction errors for specific synaptic contacts at basal dendrites.
Assuming that local membrane potentials indeed reflect an error signal, dendritic hPC predicts that these potentials should influence synaptic plasticity locally [13,14]. Such voltage-dependent plasticity (VDP) has been observed in a range of experiments [56,57,58], and is thought to be mainly mediated by the local calcium concentration, which follows the local membrane potential and modulates synaptic plasticity [51,59,60]. Based on these observations, VDP rules have been proposed that can reproduce several experiments of spike-timing dependent plasticity in a unified picture [61,62]. A consequence of locally organized VDP is that inhibition strongly modulates synaptic plasticity in a very localized manner [49,63,64,65,66]; Hayama et al [64] for example found, that this modulation spreads less than 15 micrometers on dendrites. The local E/I balance therefore is a central determinant of synaptic plasticity, which-consistently with dendritic hPC-suggests that neurons purposefully incorporate it into neural learning.
Are the VDP rules that can be derived from dendritic hPC consistent with these experimentally observed VDP rules? A distinction has to be made here between VDP rules in basal dendrites, Fig 2. Illustration of the effect of local inhibition on synaptic plasticity in experiment and dendritic hPC. A In experiment, plasticity is induced in proximal dendrites with long-term potentiation (LTP) protocols or long-term depression (LTD) protocols with or without GABA uncaging (i.e. inhibition) [64]. B With GABA uncaging one observes a shrinkage of dendritic spine volume of nearby (< 15 µm distance) excitatory synapses, without GABA uncaging spine shrinkage is absent (values plotted as reported in [64]). The relative change in spine volume serves as a proxy for synaptic weight change. C The observed effect of local inhibition on synaptic plasticity is consistent with the voltage-dependent plasticity rule for bottom-up connections (Eq (12) in Infobox 2.1). The main aim here is to demonstrate the qualitative agreement between experiment and dendritic hPC. Yet, also a quantitative agreement exists if elicited postsynaptic potentials in the model are set to the typical EPSPs (≈ 70 pA) and IPSPs (≈ −45 pA) that are induced by glutamate and GABA uncaging, respectively ( Supplementary Fig 1 in [64]), and assuming that temporal overlap between the backpropagating action potential and the induced EPSPs (LTP protocol) and IPSPs (LTD+GABA protocol) are the same. Learning rate and initial synaptic weight were tuned to match the experimental outcome for LTP and LTD. See [70] for further details and simulation code.
which should enable the learning of neural representations [13], and VDP in apical dendrites, which should enable the prediction of somatic spiking [14]. For representation learning in basal dendrites, we have argued that previously proposed VPD rules [61,62] can be reconciled with the VDP rules derived from dendritic hPC [13]. One prediction of these derived VDP rules is that strong local inhibition should promote the depression of excitatory synapses, an effect that has been observed in proximal dendrites of hippocampal pyramidal neurons [64] (Fig 2; see also [67]). This is interesting, since the selective depression of excitatory synapses in face of inhibition leads to a lesser E/I balance, contrary to the locally balancing plasticity discussed above. Yet, the interplay of such unbalancing (for bottom-up connections) and balancing (for lateral inhibition) VDP rules is perfectly consistent with dendritic hPC, and enables optimal representation learning [13]. For the learning of apical connections an explicit correspondence to experimental VDP still has to be proposed. Experiments show that synaptic plasticity close to and far from the soma behaves vastly different [26,68,69], which could support the different requirements for basal and apical synaptic plasticity in dendritic hPC. While more experimental and theoretical work is needed to clarify the connections between dendritic hPC and experimental VDP, these results suggest that cortical pyramidal neurons in principle are suited to implement the learning algorithm proposed by dendritic hPC.

A diversity of inhibitory interneurons is required for dendritic predictive coding
Since pyramidal neurons in general only excite other cells, a diverse pool of inhibitory interneurons is required to implement the dendritic hPC model. Diverse, because inhibition has to act with different purposes on different parts of the dendritic tree of pyramidal neurons: First, inhibitory interneurons are needed that balance bottom-up inputs to basal dendrites via lateral connections, to compute bottom-up errors and coordinate neural responses [46]. Second, inhibitory interneurons are also needed for bottom-up inhibition of basal dendrites, which might require another type of interneuron since bottom-up inhibition relies on different plasticity rules than lateral inhibition [13]. Last, even more types of inhibitory interneurons would be required to mediate top-down inhibition, because inhibition alone at apical dendrites has a very weak effect at the soma, meaning that apical feedback is ineffective at suppressing somatic spiking [50]. To properly learn top-down inhibitory connections it therefore might be necessary to employ more complex interneuron circuits with disinhibition mechanisms, as suggested for example by models for the learning of prediction mismatch responses [71].
These are strong requirements, but indeed, cortex exhibits a wide array of inhibitory interneurons, some of which resemble the suggested connectivity patterns [72,73]. One of the defining network motifs of cortex for example is implemented by parvalbumin-expressing (PV) interneurons, which mainly provide broad feedback inhibition within populations of pyramidal neurons [24,73,74,75]. PV positive, fast-spiking basket cells alone make up around 40-50% of all interneurons [72], and are especially adapted to tightly control pyramidal neuron spiking and the cortical E-I balance via very fast inhibition to somata and basal dendrites [73,76]. Here, inhibitory interneurons can very specifically cancel thalamo-cortical (bottom-up) excitatory synapses [77]. This motif directly corresponds to the balancing lateral inhibition to basal dendrites that is central to dendritic hPC. PV interneurons also seem to be responsible for the Gamma oscillations that arise in dendritic hPC [76], further strengthening this link. Somatostatin-expressing (SST) interneurons in contrast mainly inhibit apical dendrites and are typically innervated by facilitating excitatory synapses [73], which enables them to more slowly control the influence of top-down inputs. A wealth of recent studies showed that these diverse inhibitory interneurons are crucial for cortical networks to respond with great stability to sensory inputs, and to incorporate feedback from other cortical areas into their computations [66]. Therefore, while the mapping of dendritic hPC to cortical interneuron connectivity will have to be made more explicit, the rich pool of cortical interneurons can certainly support the computations proposed by dendritic hPC.

How can error responses arise in prediction neurons?
One of the central features of classical hPC is its ability to explain a variety of experimental observations through the concept of error neurons. Quite directly, error neurons can give a unified account of mismatch responses in cortex, which are neural responses that signal (or seem to signal) the mismatch between an internal model and sensory data, and would not be expected in a naive feedforward account of sensory processing [43]. Error neurons have also been argued to explain other observations that are seemingly unrelated to error computation [43], such as extra-classical receptive field effects in visual cortex [6]. An important question for dendritic hPC is, therefore, if these experimental observations can also be explained in a model without error neurons. How some of these effects can occur in models without error units, such as omission responses or expectation suppression, has been discussed before [5,43]. In the following we will focus on the less discussed effects of mismatch responses in visual cortex [78] and top-down modulated extra-classical receptive field effects [6], and outline how these types of responses can emerge in the prediction neurons of dendritic hPC.
A prime example of mismatch responses has recently been observed in visual cortex in neurons respond-ing to optic flow [78,79]. In this specific experimental setup mice move through a virtual environment (Fig 3E,F). When a mismatch between optic flow predicted from egomotion and the presented optic flow is induced, this mismatch is signaled by V1 layer 2/3 neurons [79]. The interpretation of these signals in terms of error neurons is straightforward: Predictions of optic flow from motor-related areas (M2) are subtracted from prediction neuron activity in V1 that encode all optic flow, and the result of this subtraction is represented in layer 2/3 error neurons (Fig 3B). In dendritic hPC the explanation of such mismatch responses is subtly different: Here, motor and visual areas can be thought to jointly encode optic flow. Hence, V1 layer 2/3 prediction neurons should encode the residual optic flow when self-generated optic flow is canceled via efference copies (Fig 3C,D,G) [5,80]. Such a representation is efficient, since here the redundancy between responses in V1 and M2 is reduced. It can also be very useful, for example to enable a moving observer to rapidly identify objects that move independently of a static surrounding [81,82,83] (A common belief is that also mismatch responses of dedicated error neurons in classical hPC could serve these two purposes, which we have argued is not the case; see [80] for details). This interpretation of mismatch responses could explain why mismatch responses in V1 seem to be mixed with prediction responses [78,84]. Similar explanations can also be applied to other such observations, e.g. audio-visual suppression in V1 [85]. If correct, this could signify that cortex, already at the earliest levels of processing, encodes sensory stimuli as a whole in order to improve efficiency and integrate multisensory information.
Another central experimental observation that has been explained with error neurons in hPC is the extra-classical receptive field effect of endstopping [6]. To induce this effect, bars with a fixed orientation but varying lengths are presented to a subject, and activity in visual cortex (layer 2/3 or layer 4) is measured. Two surprising observations can be made: First, the response of a neuron with a matching orientation tuning increases with increasing length when the bar is short, but when the bar extends over the classical receptive field, the response strongly decreases with increasing length [87]. Second, this extra-classical receptive field effect is reduced when feedback from higher-level areas is disabled [87]. In classical hPC these effects are explained with a strong prior expectation of a higherlevel area to observe long bars, which occur more frequently in natural images than short bars. Error neurons in a lower-level area will thus respond stronger for short bars, since they are less predicted from high-level feedback [6]. In dendritic hPC, where only prediction neurons are present, endstopping cannot be explained by this mechanism. However, recent theoretical work showed that endstopping behavior (and other extra-classical receptive field effects) also occurs in prediction neurons, where top-down connections strengthen this effect [88,89]. Here, endstopping is mainly mediated by lateral inhibition between neurons with overlapping receptive fields [89]. Top-down connections from higher-level areas predict the activity patterns that arise from these lateral interactions and enhance them, which strengthens endstopping behavior [88]. This cooperation of lateral and top-down interactions could be important to help the network to cope with noise in the inputs and improve visual processing [88], and has been widely observed in visual cortex [90,91,92,93,94].

Open challenges for dendritic predictive coding
As we have seen, the idea that neurons compute errors in their dendrites for hierarchical processing is consistent with many aspects of cortical connectivity and dynamics, but it also raises many questions.
Here, we will discuss the most central open challenges that address, first, the micro-level of dendritic organization, second, the level of neural populations, and, third, the macro-level of how dendritic hPC could be implemented in the laminar organization of neocortex.
On the micro-level dendritic hPC employs a very simple picture of dendritic organization, whereas in reality neural dendrites are rather complex entities [95]. First, to be mathematically equivalent to classical hPC, dendritic hPC assumes that single bottom-up connections and corresponding balancing lateral connections are perfectly separated from other inputs to the neuron [13]. Such a strict separation would require a large amount of balancing lateral connections, and is not present in neural The mathematical foundation of hPC are generative models, which are probabilistic models of (sensory) data. They formalize the idea that the brain builds a model of sensory data, and hence the world. The neural architectures, dynamics and plasticity rules always arise from a specific generative model [4,6], which is why it is helpful to understand the basic notions of generative modeling when talking about hPC. A generative model assumes that the observed distribution of sensory data can be well described by a process that generates the data from unobserved (latent) variables. This process is formalized in terms of a conditional probability distribution p θ (data|latent), where θ are parameters of the distribution. In order to ease reasoning with these conditional probability distributions, the generative model is often depicted in the form of a graphical model, which expresses conditional dependencies between variables (Fig B). In this example, it is assumed that images in a dataset can be generated by combining different objects (plus some noise), which is indicated by the arrow.
In hPC (or causal inference in general) it is as-sumed that, given the sensory data and prior expectations, the brain infers a consistent explanation (also referred to as representation or prediction) of the data in terms of latent variables. This requires to invert the generative model that the brain (implicitly) has of the world, i.e. to compute p θ (latent|data). This inference in the inverted model can be executed by a neural network, where the activity of prediction neurons corresponds to the value of certain latent variables (Fig B).
Explaining away. In many instances the data is not only explained by a single variable, but by several at once (Fig C). Images, for example, could be explained in terms of objects and faces. In this case, when inferring the best explanations from the data, one latent variable must not explain aspects of the data that are already accounted for-i.e. explained away-by other variables. In the networks this typically introduces inhibitory interactions between prediction neurons, as neurons should not encode what is already encoded by other neurons [86]. In classical hPC this interaction is mediated by error neurons, while in dendritic hPC prediction neurons directly inhibit each other at the dendrites ( Fig C). Note, that in general explaining away already occurs between prediction neurons within a single level, as all these neurons explain the same data.  . These neurons are driven by visual input, while M2 tries to predict (i.e balance) this input, resulting in neural responses when drive and prediction do not match [71]. C In dendritic hPC M2 is seen as explaining optic flow jointly with V1. This introduces explaining away effects between V1 and M2. D Explaining away means that in the corresponding neural circuit M2 should learn to balance dendrites of V1 neurons. This effectively cancels activity in V1 that can be predicted from M2. Hence, mismatch responses emerge in V1 prediction neurons (orange box) by the same superficial mechanism as in error units of classical hPC. B,D For clarity, only connections that are essential for mismatch responses are shown. E Experimental setup to induce mismatch responses [79]. A mouse is placed in a virtual environment, while the head is fixed. Egomotion of the mouse (red arrow) results in visual flow (green arrows) that is displayed on a screen. F Sample optic flow stimuli that are presented in our model. A rotation to the left would predict uniform visual flow to the right. Two mismatch conditions are also presented, where center optic flow is slower (#1) or faster (#2) than expected. G Simulation of optic flow mismatch responses with the circuit in (D), reproduced from [80]. We find one visual neuron that learned to react specifically to slower center optic flow than expected (neuron #3), and one that reacts to faster flow than expected (neuron #4), which is similarly found in experiment [79]. dendrites, where it is known that correlated excitatory synapses cluster together [96,97,98]. One suggestion is that synapses in a cluster could share predictions that are relevant for all these synapses, and by that minimize the number of lateral connections [13]. In the beginning of learning, local inhibition could provide a backbone on which excitatory synapses are organized [99]. How exactly such a plasticity scheme could enable the locally coordinated learning of predictions is still unclear. Second, neural dendrites integrate synaptic inputs in a nonlinear fashion [100], which can greatly enhance the computational power of neurons [95]. The dendritic hPC model as we discuss it here, on the other hand, so far has only been derived under the assumption of linear dendritic integration for the linear encoding of signals. Future work will have to understand how nonlinear dendrites can be integrated into the framework, and how they can enable a nonlinear, and thus more versatile, encoding of sensory signals.
On the level of neural populations it has to be understood how exactly dendritic hPC relates to cortical lateral connectivity. In section 3 we have already discussed the question of how the diversity of inhibitory interneurons supports the computations in dendritic hPC. Another interesting issue is how the extensive excitatory lateral connectivity (which seems especially prevalent within layer 2/3) [24] can be incorporated into the framework. Evidence suggests that cortex operates in a reverberating regime, which allows to integrate information over tuneable timescales and could be mediated by lateral excitatory connectivity [101]. Similarly, it is thought that lateral connections provide a substrate for associative memory and pattern completion in cortex [102,103]. Such mechanisms have been modeled in single-level models of spiking neurons [40,104,105]. Here, functional assemblies and temporal sequences can be learned with spike-timing dependent [40,105] or voltage-dependent plasticity [106]. An open question is how these mechanisms can purposefully interact with the learning of predictions in a hierarchical model (but see [107] for a suggestion without learning).
On the macro-level of cortical circuits and lamination, an important question is what the computational roles of pyramidal neurons in the different layers of (neo-)cortex are [17]. In classical hPC, based on neocortical connectivity, an influential theory of these roles has been brought forward by Bastos et al [4] (Fig 4C). This theory states that errors and predictions are first computed in layer 2/3, while layer 4 and 5 neurons primarily redistribute signals. This role of deeper cortical layers is also compatible with theories of cortical evolution [108]. Ancestral amniote (reptiles and mammals) cortex was based on a 3-layer architecture, with a single layer of pyramidal neurons, and is thought to have operated relatively independently of other brain structures. Deeper layers in neocortex might have migrated from previously separate neural populations to cortex in order to integrate cortical neurons more deeply with the rest of the brain and other cortical areas [108]. This idea is supported by evidence from studies of brain anatomy and cell-type markers [109,110,111] (Fig 4A,B).
For dendritic hPC we therefore suggest the working hypothesis that, similar to the theories of Bastos et al [4] and Douglas and Martin [24], deeper layers mainly act as long-range communication hubs for cortical integration, while the associative and computational role of the neurons in the dendritic hPC model is performed by pyramidal neurons in layer 2/3 ( Fig 4D). Cortical connectivity can support this idea: Layer 2/3 pyramidal neurons would send predictions, directly or mediated by layer 4 neurons, up the hierarchy where they are integrated at basal dendrites, and, directly or mediated by layer 5 neurons, down the hierarchy where they are integrated at apical dendrites [4,17,24]. Also the different lamina-specific coding properties of pyramidal cells are compatible: Layer 2/3 neurons exhibit sparse activity, which is suited for the computational role of dendritic hPC [74,75,112]. As discussed before, the Gamma rhythm of these neurons could be indicative of an efficient neural code. Layer 5 neurons, in contrast, employ a dense code, which can effectively broadcast information to long-range targets [112]. Future work will have to revisit this working hypothesis, and examine in what sense the suggested role of deeper layers is an oversimplification (possible, complementary roles have been discussed before, e.g. [24]). How could dendritic predictive coding be embedded into neocortical microcircuits and lamination? A Core circuitry of mammalian neocortex, as shown in [109,111]. Input neurons in layer 4 (green) receive sensory information from the dorsal thalamus, layer 2/3 neurons further process this information, and output neurons in layer 5 (red) project to the brainstem. B Theories of cortical evolution hypothesize that these input, intratelencephalic (IT) and output cells are homologous to cells that existed in the ancestral amniote pallium [111]. In birds and non-avian reptiles these cells are organized in architectures that differ from the laminar organization of mammalian neocortex [111]. C The predictive coding microcircuit as proposed by [4] (here presented in a simplified form) follows the organization of the neocortical microcircuit. Predictions (r i ) and prediction errors (e i ) are computed in layer 2/3. Deeper layers mainly act as communication hubs by copying signals from layer 2/3. D Speculative microcircuit for dendritic predictive coding. Here, deeper layers fulfill the same function as communication hubs, but layer 2/3 only computes predictions. More connections (especially within layer 2/3 between areas) might exist [17], but are left out here for simplicity.

Summary & Outlook
Since its conception over twenty years ago, hierarchical predictive coding has been considered one of the most promising unifying theories of cortical computation, but-in its classical form-it is still facing substantial questions regarding its biological plausibility. Here, we outlined an emerging hierarchical predictive coding scheme based on dendritic error computation, which is functionally equivalent, but provides solutions to the most glaring open problems of the established theory of classical hPC: First, it can explain the lack of clear empirical evidence for the coexistence of error and prediction neurons [42,43], and second, it overcomes the unresolved question of how learning can be efficiently implemented with spiking error neurons [8]. Moreover, it has the potential to explain a broad range of additional experimental observations: From the idea that prediction errors are represented at neural dendrites, it directly follows that synaptic inputs to basal dendrites should be locally balanced by lateral inhibition, which is a network motif that is indeed ubiquitous in cortex [9,24,26,48]. Also, the learning rules derived in dendritic hPC are consistent with the observation that synaptic plasticity is strongly modulated by the local voltage in dendrites [62,64]. Furthermore, dendritic hPC can relate these microscopic properties of neural dendrites to neural dynamics and learning on macroscopic scales, and shows how they could give rise to the neural spike response characteristics [9], receptive fields [13,88] and the influence of top-down connections [88], that are observed in cortex.
These advances open up several exciting paths for future research. Empirically, the predictions of dendritic hPC should be tested directly in experiments, and specialized experiments should be designed that can distinguish between the two competing theories of classical and dendritic hPC. The latter will be an auspicious but challenging endeavor: First, because classical hPC as of yet does not make clear predictions on the level of single neurons. Second, because often indirect measures of neural activity (e.g. EEG, fMRI) have been used to search for evidence of classical hPC, and it remains to be worked out in detail how error computation in specialized neurons and in dendrites would differ in these measures. Third, and most importantly, because the expected computations of prediction neurons are the same in the two theories-even though classical and dendritic hPC give competing answers to the question of how exactly inference is performed in neural circuits, they still are just two possible implementations of the same underlying mathematical framework. This, however, also creates opportunities: Many of the important conceptual insights that have been gained over the last years in classical hPC, such as what role the precision of predictions could play in cortical computations [113], can be transferred to dendritic hPC, where they will acquire new meaning in terms of neural physiology and dynamics.