Predictive Coding beyond Gaussian Distributions
Abstract
A large amount of recent research has the far-reaching goal of finding training methods for deep neural networks that can serve as alternatives to backpropagation (BP).
A prominent example is predictive coding (PC), which is a neuroscience-inspired method that performs inference on hierarchical Gaussian generative models.
These methods, however, fail to keep up with modern neural networks, as they are unable to replicate the dynamics of complex layers and activation functions.
In this work, we solve this problem by generalizing PC to arbitrary probability distributions, enabling the training of architectures, such as transformers, that are hard to approximate with only Gaussian assumptions.
We perform three experimental analyses.
First, we study the gap between our method and the standard formulation of PC on multiple toy examples.
Second, we test the reconstruction quality on variational autoencoders, where our method reaches the same reconstruction quality as BP.
Third, we show that our method allows us to train transformer networks and achieve performance comparable with BP on conditional language models.
More broadly, this method allows neuroscience-inspired learning to be applied to multiple domains, since the internal distributions can be flexibly adapted to the data, tasks, and architectures used.
Introduction
The last decade has seen an explosion of machine learning research fueled by the collection of an unprecedented amount of data and the development of models that can make use of it.
Starting with AlexNet [Krizhevsky et al., 2012], deep
[Rumelhart et al., 1986] have been established as the best-performing models in many fields [Silver et al., 2016,
He et al., 2016, Brown et al., 2020, Ramesh et al., 2021, Devlin et al., 2018].
Despite reaching human-level performance in several tasks [Silver et al., 2016, Vinyals et al., 2017, 2019], we are still far from artificial general intelligence.
The trend has been to constantly increase the number of parameters in such networks, from millions [Devlin et al., 2018] to hundreds of billions [Brown et al., 2020].
The limitations and drawbacks given by the large size of modern architectures have motivated research that looks for alternative methods to train them.
The direction of research that has inspired this work is that of neuroscience-inspired alternatives to BP, which promise to overcome these drawbacks, due to both interesting properties of their credit assignment, such as plasticity [Hebb, 1949], and their biological hardware [Kendall et al., 2020].
These methods have two main advantages relative to standard deep learning models trained with BP.
First, it is much more feasible to train them on analog and neuromorphic chips [Kendall et al., 2020].
Second, the resulting computational models are extremely flexible in both network layout design and querying techniques [Salvatori et al., 2022a, Millidge et al., 2021, Salvatori et al., 2021, Papadimitriou et al., 2020].
These two properties could play a crucial role in overcoming the limitations of BP-based learning towards artificial general intelligence.
Predictive coding (PC) is one of the most influential theories of information processing in the brain, initially proposed to explain a large number of brain behaviours [Mumford, 1992, Friston and
Kiebel, 2009], and now also a topic of research in machine learning, thanks to the computational model proposed by Rao and Ballard [Rao and Ballard, 1999].
This method has in fact been used in supervised and unsupervised tasks [Ororbia and Kifer, 2020, Whittington and Bogacz, 2017, Han et al., 2018], with an important theoretical result: the original formulation is able to approximate the weight update of BP [Whittington and Bogacz, 2017, Millidge et al., 2020], and to exactly replicate it when introducing small variations [Salvatori et al., 2022b, Song et al., 2020].
These results are important, as they draw a strong connection with the aforementioned results obtained by BP in the last decade.
PC, however, also presents several interesting properties that make it different from BP: it has an energy-based formulation that allows the design of powerful associative memory models [Salvatori et al., 2021] and to train graphs of any topology [Salvatori et al., 2022a].
PC can also be studied from an information theory perspective, as it is a hierarchical generative model
[Rao and Ballard, 1999].
This is a strength of the model, as it has allowed such models to achieve competitive performance to standard models trained with BP on several generative tasks.
These results, however, are all obtained on simple models: sequential architectures with element-wise activations and quadratic energy functions.
Deep learning, however, has progressed far from those in recent years, and, therefore, it is necessary to evaluate the performance of PC on more up-to-date and complex architectures to obtain a complete comparison of PC against BP.
In this paper, we see that the strict Gaussian assumption is limiting when dealing with more complex architectures such as transformers, preventing PC from reaching the performance obtained by BP.
Note that this limitation is not unique to PC, but it is shared among all neuroscience-inspired methods: for example, to our knowledge, none of these frameworks has been successfully used to train language models to date.
In this work, we address this problem by generalizing PC to arbitrary distributions.
This allows us to both use Gaussian distributions when allowed, and also to deal with intractable ones by approximating them using a sampling scheme.
The resulting framework is coherent with the PC theory, as it enables the definition of layer-wise energy functions that represent prediction errors [Rao and Ballard, 1999, Whittington and Bogacz, 2017].
In standard PC networks, the error is given by the difference between the expected and actual input of a layer; here, it is defined as the KL-divergence between the expected and actual distributions.
We show that these formulations are equivalent when using Gaussian distributions, meaning that our proposed framework is a generalization of standard PC.
The results of this paper are briefly summarized as follows:
• We generalize PC beyond the assumption of a Gaussian generative model.
This lets us define prediction errors as ‘distances’ between arbitrary distributions at each hierarchical layer of a PC network, and derive a novel free-energy objective to train such networks.
• We empirically show that standard PC is ineffective in training models with complex structure and activation functions, as they cannot be approximated by a Gaussian generative model.
Our proposed method, instead, significantly outperforms it, reaching a competitive performance with BP in training both variational autoencoders [Kingma and Welling, 2014] and transformers [Vaswani et al., 2017].
This further bridges the gap in performance between state-of-the-art deep learning methods and neuroscience-inspired learning.
The rest of this paper is structured as follows.
In Section 2, we introduce the notation used throughout the paper and describe the probabilistic interpretation of PC.
In Section 3, we propose how to generalize the definition of PC beyond Gaussian generative models.
In Section 4, we evaluate the performance of our proposed method in comparison to standard PC and BP.
Finally, in Sectionsand 6, we discuss related work and provide a conclusion, respectively.
Predictive Coding: A Probabilistic Interpretation
In this work, we focus on multi-layer networks organised in a sequence of L layers.
These networks define a model M θ that learns the relationship between the input d and the target o by updating [Figure] its weight parameters θ =
( θ 1 , . .
, θ L ) .
Networks trained with BP have a forward pass, where an output ˆ o is computed from an input d , and a backward pass, where the error given by a loss function L = loss ( o, ˆ o ) is propagated back to the network.
Every layer of the model has a set of value nodes x l which contain the value of the prediction µ l (i.e., what is normally called activation of a layer), computed accordingly to the value of the previous layer. More in detail, we have µ l = f l ( x l − 1 , θ l ) , where f l is an activation function.
In PC, the prediction µ l is not stored directly inside the value nodes x l , but rather in separate prediction nodes.
The nodes x l hold, instead, the neural activation ϕ l of layer l . ϕ l is a parameter of the network that can be optimized by minimizing the so-called prediction error between µ l and itself.
Therefore, a model trained via BP consists of exclusively the parameters θ , while a PC network requires two sets of parameters, θ and ϕ , where ϕ = ( ϕ 0 , . . .
, ϕ L ) represents the neural activities of different layers (Fig. 1).
Table 1 summarises the differences between backpropagation and predictive coding.
[Table]
2.1 PC as Variational Inference
PC as a learning algorithm can be mathematically interpreted as a variational inference problem.
It is in fact possible to consider learning as an intractable Bayesian inference process that can be approximated with a tractable optimization problem [Friston, 2003, 2005, 2008].
Under this assumption, the neural activities ϕ i in a PC network represent probability distributions.
In particular, Friston based his theory of PC on Gaussian generative models.
A detailed review is provided in Millidge et al.
Let us assume we have a generative model o = g ( x ) , where o is a data point and x a set of latent variables, that is described by the joint probability p ( o, x )
=
p o | x ) p ( x ) . We need to solve an inverse problem: given a datapoint o , we need to infer the causes x that generate o through g .
Similarly to many inverse problems, this one is intractable.
In particular, we want to compute the true posterior p ( x | o ) .
However, computing it by Bayes rule as p ( x | o ) =
p ( o, x ) /p
( o ) requires the normalizing factor p ( o )
= (cid:82) p ( x, o ) dx , which is, for all but trivial problems, intractable.
Variational inference aims to approximate the intractable posterior with a family of distributions q ϕ ( x | o ) , where the parameters ϕ have to be learnt.
This is generally done via gradient descent on the KL divergence [Kullback and Leibler, 1951] between the approximated and true posterior.
The goal is to compute
[Equation]
1) by minimizing an upper bound on the divergence, called the variational free energy F :
[Equation]
The PC framework assumes a Gaussian form for the generative model p ( o, x )
= p ( o | x ) p ( x ) =
N ( o ; f ( x, θ ) , Σ 2 ) N ( x, µ, Σ 1 ) , where Σ 2 , Σ 1 , and µ are prior parameters that can optionally be learnt.
Using as variational posterior the Dirac-delta distribution * q ϕ ( x | o )
=
δ ( x − ϕ ) , we get that
[Equation]
where the entropy of q is 0.
This scheme can be applied to deep neural networks, where x does not represent a homogeneous latent space (e.g., a single layer), but is, instead, organised in a hierarchical structure, defined by the multiple layers of a PC network with widths w 1 , ..., w l and nodes x 0 , x 1 , ..., x L .
Under this premise, the generative model is as follows:
[Equation]
where µ l = f l ( x l − 1 , θ l ) , and x L corresponds to the observation layer and is set to x L = o during training.
The parameters Σ l are prior diagonal covariance matrices, which can be optionally learnt, and µ 0 is an arbitrary prior that can be set to some given data d .
This is equivalent to the training of a supervised network with data point d and label o .
The energy becomes:
[Equation]
where k is a constant, ϵ l = ( ϕ l − µ l ) , and q ϕ ( x 0: L | d, o )
= (cid:81)
Ll =
δ ( x l − ϕ l ) (implying that x l = ϕ l ).
In this equation, the total energy is given by the sum of the energies
E l of every layer, where
E l := − ln p ( ϕ l | µ l ) .
By assuming identity covariance matrices (i.e., Σ l = I ) † , the energy becomes the sum of quadratic errors, introduced by Rao and Ballard [1999]: [Equation]
[Equation]
In most cases, however, the generative model depends on a set of parameters θ : p ( x 0 , . . .
, x L ; θ ) , that need to be learned according to a specific dataset.
This can be done via expectation maximization (EM)
[Dempster et al., 1977], where we first infer the best possible latent variables phi given a datapoint o (E-step) and then use them to update the parameters θ (M-step).
In practice, both these phases are achieved using gradient descent to minimize F .
More in detail, given a labelled point ( d, o ) , the input layer prior is set to µ 0 =
d , while the output layer nodes are fixed to ϕ L
= o for both the inference phase (E-step) and weight update (M-step).
During the inference phase, the weight parameters are fixed, and the node values ϕ are continuously updated via gradient descent to minimize the energy F .
This process either runs until convergence or for a fixed number of steps T .
When the inference phase ends, a weight update is performed as follows: the node values ϕ are fixed, and the weights are updated once via gradient descent on the same energy function F .
Generalization to Arbitrary Distributions
In this section, we go beyond the strict Gaussian assumption of PC.
According to eq. 5, we have that E l = − ln p ( ϕ l | µ l ) = − ln N ( ϕ l ; f l ( ϕ l − 1 , θ l ) , Σ l )) .
We can highlight the role of each ϕ i , by introducing the ·
D and · S superscripts, which, respectively, indicate that a vector value is interpreted as a distribution (i.e., a vector of sufficient statistics that uniquely identifies a probability distribution, such as the mean u of a Gaussian distribution), or as a single sample. The · S , · D notation does not, in any case, imply any transformation of the value itself. We get that
[Equation] Thus, neural activation ϕ l is simultaneously interpreted both as ϕ S l and ϕ D l .
This subtle difference has never been highlighted in standard works using hierarchical Gaussian models, since ϕ S l corresponds to the maximum likelihood estimation of the Gaussian distribution N ( ϕ D l , Σ l ) , and thus ϕ S l = ϕ D l .
Assuming a Gaussian form for the generative model could, however, become a limiting factor when considering complex architectures.
For example, a layer employing a softmax activation cannot be easily approximated through a multi-variate Gaussian, since the function introduces a strong dependency between the nodes (i.e., their values have to sum to 1 ).
As we will show in the next sections, using softmax activation functions can hinder the ability of a network to learn using the standard definition of PC, and hence a generalized formulation that goes beyond the standard Gaussian assumption is needed.
In order to generalize and extend the canonical formulation of PC, we do the following: instead of directly maximizing the likelihoods p l := p ( ϕ S l | µ D l ) , we assume that this process is happening repeatedly between each pair of consecutive layers for a single optimization step.
We consider the nodes x l as storing the sufficient statistics ϕ
D l of an arbitrary distribution X l ( ϕ D l ) , ‡ we draw N sample points from it, s ( i ) l ∼ X l ( ϕ D l ) , i ∈ { 1 , . . .
, N } , and we minimize each individual likelihood p ( i ) l = p ( s ( i ) l | µ D l ) .
Furthermore, we remove the Gaussian assumption and consider µ D l = f l ( ϕ Dl − 1 , θ l ) to be a parametrization of a generic distribution (cid:98) X l ( µ D l ) .
By doing so, the node values ϕ l are interpreted exclusively as distribution parameters: both the energies E l and the activations µ D l are functions of ϕ D l .
It follows that the variational free energy F is also a function of the expected values given by the likelihoods p ( s ( i ) l | µ D l ) , i ∈ { 1 , . . .
, N } , for each layer l .
The energy of each layer is then defined as:
[Equation]
A detailed derivation of the above equation is presented in the supplementary material.
Knowing that the cross-entropy between two distributions H ( a, b )
=
D KL [ a || b ] + H ( a ) and that H ( a ) ≥ 0 , the total energy of the network can be optimized by minimizing
[Equation]
This follows, as the entropy of X l ( ϕ D l ) can be assumed as being a constant depending on the training data.
Figure 2 highlights the difference between the original and new PC formulation.
This definition of the variational free energy F KL does not rely on the Gaussian generative assumption, and (as long as the KL divergence between X l and (cid:98) X l can be efficiently computed) there is no limit on the kind of distribution that can be used.
Throughout our experiments, we assumed that the distributions
X l and (cid:98)
X l belong to the same family, but different families can be used in different layers.
In the supplementary material, we show how F KL is equivalent to F when assuming a Gaussian generative model.
We also analyze the learning dynamics defined by applying the Expectation-Maximization (EM) algorithm to Eq.
Experiments
We compare the results of different models trained with BP and PC on various tasks.
The main goal is to make PC competitive with BP for complex deep neural architectures.
Only recently, PC has begun to be applied to train neural networks for classification tasks Whittington and Bogacz [2017], with similar performance but a greater versatility compared to BP Salvatori et al.
[2022a]. We show that our extended probabilistic formulation can be applied to more complex architectures.
We refer to each specific version of PC by specifying its energy function. [Figure]
PC F KL noticeably outperforms PC F , reaching performances comparable with BP.
This is true, especially for M 2 , which reflects the most commonly used architecture among the three.
The x-axis represents the number of epochs.
4.1 Classification
As a proof-of-concept experiment, we have trained different models on classification tasks for both the MNIST [Deng, 2012] and {+CIFAR
+}
[Krizhevsky et al.] datasets.
We evaluated the final accuracy of the model when training with BP compared to PC, as well as the training efficiency, measured as improvements over epochs.
Setup: We defined three variations of a fully connected network with L = 3 hidden layers and width w = 512 :
• M 1 uses tanh as activation function for the hidden and final layers.
The mean squared error (MSE) is the loss function used for BP and to compute the test loss of both PC and BP.
• M 2 uses the softmax activation function for the final layer.
Consequently, the loss function used is cross-entropy (CE).
This architecture corresponds to the one normally used in classification tasks.
• M 3 is a copy of M 2 where the activation function of the second hidden layer is replaced with softmax .
CE is again the loss function used.
[-M    0 .0 .0 .1 .
-]
[-Accuracy Loss 
-]
Note that the experiments performed with a softmax activation in a hidden layer are merely presented with the goal of empirically validating the effectiveness of our theory, as networks of this kind have never been in practical tasks.
Effectively, M 2 represents the only widely used architecture.
We used a weight learning rate of β θ = 0 . 0001 for both PC and BP.
For PC, we used T = 32 ϕ -steps.
We assumed identity covariance matrices for the Gaussian distributions of the generative model.
Consequently, the energies F and F KL differ only for the function used for a softmax -activated layer.
For F KL , that is
[Equation]
[Equation] where X l and (cid:98) X l are discrete distributions.
Therefore, in the model M 1 , PC F KL and PC F are algorithmically equivalent (see the supplementary material).
More details about the hyperparameters we used are given in the supplementary material.
[Figure] [Figure] Results: The results are plotted in Fig.
They show that neural networks trained with BP and
PC F KL perform similarly in both M 1 and M 2 .
The original formulation of PC, on the other hand, performs much worse in all the considered experiments.
The first column of plots shows that PC and BP perform similarly when trained with fully Gaussian assumptions.
In the experiment on M 2 , the standard definition of PC is performing well, even though it is significantly outperformed by
BP and PC F KL .
When training on M 3 , however, the performances are poor.
This again does not happen when training using PC F KL , which obtains performances comparable to those of BP.
Overall, this clearly indicates that PC F is not suitable to train neural networks that do not rely uniquely on
Gaussian generative models.
Instead, we experienced a solid improvement when using the F KL energy function.
It is enough to reach the same accuracy-over-epochs ratio achieved by BP when using M 2 .
Under more uncommon architectural choices, such as M 3 , the ratio is slightly worse in favour of BP, but still decisively better than PC F .
The difference is particularly noticeable in the first epochs.
We believe it may be due to a not ideal initialization of the weights for the PC network, which is currently using the default initialization designed for BP networks [He et al., 2015].
Further research in this direction could improve training performance.
4.2 Variational Autoencoders
Variational autoencoders (VAEs) [Kingma and Welling, 2014] are models that rely on distributions different from Gaussians with fixed covariance matrix.
This follows, as the bottleneck layer b of a VAE is required to model the distributions of both the mean and the variance of the latent posterior given a sample d , p ( u b , Σ b | d ) .
However, both PC F and PC (cid:101) F are not suitable for that, as they require each layer to represent exclusively the Gaussian mean u l .
The optionally learnable parameters Σ l do not depend on the particular input sample d .
Our proposed method, however, overcomes this limitation by learning the full posterior distribution N d ( u b , Σ b ) .
This is done by considering the bottleneck layer b as storing the distribution parameters ϕ D b = ( u b , Σ b ) .
In this case, µ D b = ( (cid:98) u b , (cid:98) Σ b ) =
f b ( ϕ D b − 1 , θ b ) .
We then employ the reparametrization trick [Kingma and Welling, 2014] by sampling some Gaussian noise ¯ ϵ ∼ N (0 , 1) to compute µ b +1 =
f b +1 ( u b + ¯ ϵDiag (Σ 1 / 2 b ) , θ b +1 ) , which is fed to the next layer. More details are shown in Figure 4.
[Figure] Setup: We trained multiple VAEs on the MNIST dataset, comparing the PC and BP training algorithms.
Our architectures employed fully connected layers, with Hardtanh activation function for the hidden layers and sigmoid for the output layer.
The bottleneck layer has a total of w b = 32 (= 16 + 16) latent units.
When training with PC, we assumed Gaussian distributions with identity covariance matrix for all but the bottleneck layer, for which we model both the mean u b and the diagonal covariance matrix Σ b as explained above.
We used T = 32 , but for each data point we sampled a single ¯ ϵ at t = 0 .
We use the same weight learning rate β θ = 0 . 0001 for both BP and PC.
Further details about hyperparameters and implementation details are described in the appendix.
Results: We observed similar results on a wide range of hyperparameters.
In Figure 5, we report the performance of both training methods on two different architectures.
The final test loss is overall similar, with neither method being decisively better than the other.
The learning curves are also comparable, despite PC being generally faster than BP in the first training epochs.
By reconstructing the maximum likelihood estimation of some data points, we can observe how all models produce very similar images.
We also performed an analysis of the latent space produced by the encoders and did not detect any significant difference between the two training modes.
Figure 6 reports the results.
We sampled the latent posterior distribution by encoding a data point d and decoding multiple data points d ′ obtained by sampling from N d ( µ b , Σ b ) .
To perform a latent traversal, we encoded two different data points, d 1 and d 2 , and reconstructed the maximum likelihood estimation of the vectors obtained by interpolating the two latent embeddings.
4.3 Transformer Language Models
To show the performance of our method on more complex tasks, we have trained transformer conditional language models based on the BERT architecture [Devlin et al., 2018].
The conditional language model objective is enforced by modifying the self-attention mechanism with a triangular mask so that no position can attend to any later position in the sequence.
Setup: We use the 1B Word Benchmark dataset [Chelba et al., 2013], from which we randomly sample 200,000 training and 10,000 dev instances.
We choose to restrict the model ’s input length to 32 input tokens from a vocabulary of 8001 tokens generated by the BPE-based SentencePiece tokenizer [Kudo and Richardson, 2018].
We use one transformer block with one head and a hidden size of 128 throughout the model.
For the PC networks, we assume Gaussian distributions with identity covariance matrix for all but the layers that employ a softmax activation function (i.e., the attention layers [Vaswani et al., 2017]).
In the latter case, we assume a categorical distribution for the generative model.
Consequently, the energy function for those layers is the one defined in Eq.
More implementation details and the hyperparameters are given in the supplementary material.
Results:
For each model, we compare the three training methods: BP , PC F , PC F KL .
We found it beneficial to run multiple weight updates for a single training iteration when using PC F KL , but not for PC F where it led to instability.
We run a hyperparameter search for each training method, select the best models, compare their training curves, and their test performance, and show qualitative examples of model predictions.
Figure 7 shows that PC F KL significantly outperforms PC F in terms of test perplexity, while having a more stable training curve.
We believe that this is because [Figure] of the softmax in both the attention mechanism and the output layer of the transformer model.
The performance of PC F KL is close to that of BP and both training curves look stable.
In practical terms, the language models trained by BP and PC F KL do not differ significantly on the test set.
In some cases, the predictions given by PC F KL are closer to the ground truth, e.g., for “Yet the bank and its executives are still ready to support specific Democratic [candidates]”, PC F KL predicts “leaders” and “candidates” as top-2 choices.
All models show failure in commonsense reasoning, e.g., for “I’ve been dreaming about this since I was a [child]” they fail to assign “child” with > 1% probability, which shows the limitations of small language models.
More examples are given in the appendix.
Memory consumption and computational complexity
Memory consumption : predictive coding, in contrast to backpropagation, stores µ and ϕ as different variables, which results in some memory overhead.
On the contrary, the number of weights and training parameters used doesn’t change between BP and PC.
Therefore, if M BP is the memory consumption of training a model using BP, we have that, in general, M PC < 2 · M BP .
Actual values depend on the architecture and hyperparameters chosen.
Computational complexity : the complexity of a single forward pass in terms of the number of operations is comparable between PC and BP. The same can be said for the backward pass. However, in accordance with the EM algorithm, it is necessary to perform multiple updates on the neurons x before updating the network weights θ . This results in a multiplicative factor that can impact performance compared to BP.
Nonetheless, from our experiments, we noticed that even a value as low as T = 4 or T = 2 , where T is the number of updates of the neurons before performing an update of the parameters, is sufficient given the right hyperparameters.
In fact, the experiments on the transformer reached the best perplexity with exactly T = 5 .
Furthermore, we can take advantage of the features of PC.
One of its major strengths is that each layer computation (both in the forward and backward pass) is local and, therefore, can be executed in parallel, removing one of the main bottlenecks of BP when training deep networks (i.e., the computations induced by each layer have to be executed sequentially).
Thus, we expect PC to scale well on large architectures and to bring huge improvements on neuromorphic hardware.
Finally, it has already been demonstrated that the speed of energy-based networks can be greatly increased by implementing the relaxation on analog hardware [Foroushani et al., 2020, Hertz et al., 1997], potentially resulting in energy-based networks being faster than backpropagation.
Thus, one scientific indication of this work is that the “analog-hardwarefriendly” predictive coding can have reasonable performance on transformers, which opens the door to designing fast hardware-implemented transformers.
Related Work
In the last years, an active research direction that lies at the intersection of machine learning and cognitive science focuses on finding training algorithms for deep neural networks that have a degree of biological plausibility while obtaining good results on machine learning benchmarks.
The most popular ones are PC [Rao and Ballard, 1999, Whittington and Bogacz, 2017], equilibrium propagation [Scellier and Bengio, 2017, Scellier et al., 2018, Scellier and Bengio, 2019], and target propagation [Lee et al., 2015, Meulemans et al., 2020, Ernoult et al., 2022].
These methods share multiple similarities, both theoretically and in terms of performance.
The first two methods, PC and equilibrium propagation, are able to approximate the weight update of BP when provided with a label that is close in distance to the neural activities of the last layer
[Whittington and Bogacz, 2017, Scellier and Bengio, 2019].
Target propagation fails to have this property, but instead has been shown to approximate Gauss-Newton optimization [Meulemans et al., 2020].
However, PC possesses many unique properties that these methods lack.
PC networks can in fact be used to produce efficient associative memory models [Salvatori et al., 2021], have an update mechanism that produces better learning properties than BP under specific conditions [Song et al., 2022], and allow training on graphs of any topology [Salvatori et al., 2022a].
Furthermore, they have achieved good results in classification [Han et al., 2018] and generation tasks [Ororbia and Kifer, 2020].
For a recent survey on these aspects, see [Millidge et al., 2022].
To conclude, we are not aware of any neuroscience-inspired learning method before this work that is able to generalize to complex tasks such as language modeling.
Progress in this direction is promising, as one of the main limitations of modern architectures is that they are extremely computationally expensive to be trained, with large-scale models sometimes requiring hundreds of GPUs for several weeks [Brown et al., 2020].
On the other hand, significant breakthroughs on neuromorphic and analog hardware have recently been achieved [Strukov et al., 2008, Sebastian et al., 2020], which can exploit the aforementioned properties of neuroscienceinspired learning methods, as shown in [Kendall et al., 2020], where the authors simulated the training of a multilayer network on an analog chip in an end-to-end fashion.
There has been a lot of research done towards bridging the gap in performance between state-of-the-art deep learning methods and neuroscience-inspired learning.
Both fields can benefit from each other by drawing inspiration from each other’s techniques.
In neuroscience, understanding how the brain learns to associate different areas (e.g., visual and motor cortices) to successfully drive behaviour is of fundamental importance [Petreanu et al., 2012, Manita et al., 2015, Makino and Komiyama, 2015,
Poort et al., 2015, Pakan et al., 2016, Zmarz and Keller, 2016, Attinger et al., 2017].
However, how to correctly modify synapses to achieve this has puzzled neuroscientists for decades.
This is often referred to as the synaptic credit assignment problem [Rumelhart et al., 1986, Sutton and Barto, 1998,
Roelfsema and van Ooyen, 2005, Bengio, 2014, Lee et al., 2015, Roelfsema and Holtmaat, 2018], for which the BP algorithm provides an elegant solution.
Conclusion
The main motivation behind this work was to make PC competitive with BP for complex deep neural architectures.
The tasks in this work are among the most popular and important in the field: image generation and language modelling.
In the first case, we trained a variational autoencoder.
This model is fully Gaussian, but the bottleneck requires explicitly computable variances.
While variations of
PC with trainable variances are already defined in the literature [Millidge et al., 2021], they do not allow dependencies between the variance and the input.
Rather, they act as a regulariser within the network.
Consequently, they have not been used as a sampling scheme in a specific layer of a PC network.
In the second case, we trained a transformer model, intractable before by PC networks, due to the presence of attention (and hence softmax ), and showed results comparable to those of BP.
Future work includes applying this method to other complex deep learning architectures, with the far-reaching goal of scaling PC to large-scale machine learning tasks and hence further closing the gap with BP-based learning. Acknowledgments
This work was supported by the Alan Turing Institute under the EPSRC grant EP/N510129/1, by the AXA Research Fund, the EPSRC grant EP/R013667/1, the MRC grant MC_UU_00003/1, the BBSRC grant BB/S006338/1, and by the EU TAILOR grant. We also acknowledge the use of the EPSRC-funded Tier 2 facility JADE (EP/P020275/1) and GPU computing support by Scan Computers
International Ltd.
Yuhang Song was supported by the China Scholarship Council under the State
Scholarship Fund and by a J.P. Morgan AI Research Fellowship. A F KL Reduces to F under Gaussian Assumptions In this section, we prove that PC F KL is a generalized version of PC and, therefore, it retains all its properties and previously achieved results when assuming a Gaussian generative model. Particularly, we show that the newly introduced energy function F KL reduces to the PC original energy formulation
F and, almost exactly, (cid:101) F , when reintroducing the Gaussian assumptions for the generative model. Consider the KL divergence formulation and a layer l . As per Eq. (9), E l := D KL
[ X l ( ϕ l ) || (cid:98) X l ( µ l )] .
If we assume that X l and (cid:98) X l are multivariate Gaussian distributions with means u l , (cid:98) u l and fixed diagonal covariance matrices Σ l , (cid:98) Σ l , we have that [Equation] By setting Σ l = (cid:98) Σ l = I , u l = ϕ l and (cid:98) u l = µ l , then 2 E [Equation]
(cid:88)
[Equation]
(12) which equals the energy function for each layer used in Eq.
If, instead, we assume that (cid:98) Σ l is a learnable parameter associated with layer l (that is, (cid:98) Σ l ∈ θ l , while keeping Σ l = I ), we obtain:
[Equation]
where k ′ is a constant.
By substituting ( ϵ 2 l,i + 1) = ϵ ′ 2 l,i , E l corresponds to the layer energy function obtained in Eq. B Biological Plausibility
Biological plausibility is a generic concept in the literature, often used to state that a specific family of models behaves similarly to biological neural networks present in our brains. However, different definitions of biological plausibility exist in the literature, and a model can be considered biologically plausible according to some definitions and not others. In what follows, we refer to the definition introduced in Whittington and Bogacz [2017], mostly restricted to local computations and plasticity. We now discuss how our framework fails to satisfy them at the most general level, and how to address this limitation.
Particularly, the learning dynamics determined by the F KL energy respects the PC assumptions defined by Whittington and Bogacz [2017] at the layer level. Particularly: • Local computation : the activity of each layer depends only on the activities of its input nodes and their synaptic weights (i.e., µ l = f l ( ϕ l − 1 , θ l ) ). • Local plasticity : synaptic plasticity only depends on pre and post-synaptic nodes.
In fact, to minimize F KL , we take the derivatives
[Equation]
and, analogously,
[Equation]
where the terms of both summations only depends on ϕ l , ϕ l +1 , and ϕ l − 1 .
However, this does not guarantee that the above two properties are satisfied at the neural level, as the exact neural circuit employed within each layer strictly depends on the distribution families chosen for (cid:98) X l and X l .
Consequently, while the original formulation of PC has some degree of biological plausibility, this may not be true in the general proposed framework.
This is because we do not set any limit on the complexity of possible distributions.
This could also have repercussions on eventual implementations on analog and neuromorphic hardware.
Hence, an interesting open problem is understanding which classes of probability distributions are biologically plausible, and which allow our framework to be implemented on these emergent technologies.
Researchers interested in developing biologically plausible models, could then only restrict their study to specific classes of probability distributions.
The same applies to researchers interested in implementing models on analog circuits.
C A More Detailed Analysis of Learning Dynamics of F KL
In what follows, we explicitly derive the update rules for the two classes of distributions discussed in the main body of the paper: categorical distributions and Gaussian distributions with non-fixed variance.
Categorical distributions : A PC layer following a softmax activation function represents a categorical distribution over w l elements.
Each node stores a different probability mass value.
{+We have that, at each time step t : ∂ϕ l,j [Equation] 14) where E l +1 = 
 when l = L .+}
Furthermore, [Equation] l,j,k [Equation]
where µ l = f l ( θ l ϕ l − 1 ) . Gaussian distributions : As shown in Section 4.2, we can model a full Gaussian distribution N ( (cid:98) u l , (cid:98) Σ l ) , with ( (cid:98) u l , (cid:98) Σ l ) = µ l = f l ( ϕ l − 1 , θ l ) .
In this scenario, the layer l parameterises the distribution N ( u l , Σ l ) , and ϕ l = ( u l , Σ l ) . We are, again, assuming diagonal covariance matrices. The dynamics are as follows:
[Equation]
and
[Equation]
where ϵ l = ( u l − (cid:98) u l ) and j ′ = j − w/ 2 .
D Derivations of the Equations Used in this Work
In this section, we provide more explicit derivations for several of the equations presented in this work.
By doing so, we hope to ease a detailed understanding of the mathematical framework that we defined.
• Eq. 5 : [Equation]
and
[Equation] Gaussian generative model
[Equation] [Equation] l is a diagonal matrix • Eq
[Equation]
// definition of H • Eq.
[Equation] E Implementation Details
In this section, we provide a detailed description of the models and parameters needed to reproduce the results presented in this work.
Note that our goal was to compare the performance of different training methods. Hence, we do not aim for state-of-the-art results, but rather a comparable performance across the different training methods for each employed architecture. E.1 Classification Networks We used fully connected feedforward networks composed by a sequence of L ∈ { 3 , 4 , 5 } fully connected layers of width w ∈ { 256 , 512 , 1024 } .
The weights learning rate was set to β θ = 0 . 0001 . We also experimented with different node learning rates β ϕ ∈ { 0 . 01 , 0 . We used T = 32 ϕ -steps and initialized the node values at t = 0 using a forward pass, as suggested by Song et al. We used the Adam optimizer to optimize the weights of the model, while we used a stochastic gradient descent optimizer for the nodes x .
We did not find any relevant differences in the observed relative performance of the three learning methods among the various combinations of hyperparameters tested. The results reported in Fig. 3 were obtained with w = 512 , L = 3 , and β ϕ = 0 . We found that using ReLU instead of tanh as activation function significantly reduces the accuracy achieved by PC (at least with the highly-specific architectures used for this task).
We used fully connected layers for both the encoders and the decoders. We trained several models with L ∈ { 2 , 3 } layers for both encoder and decoder and width w ∈ { 256 , 512 } . We used 32 latent units for the bottleneck layer, divided equally to store mean and variance.
The activation function used was tanh . Learning rates and optimizers are the same used for classification networks.
The variance in the results reported is due to different combinations of the hyperparameters chosen to obtain one or the other architecture. In Fig. 5, we reported the learning curves for two models. The choice was completely random to highlight the comparable performance of BP and PC on a general architecture.
E.3 Transformer Language Models
The 8001-token vocabulary is automatically generated based on a portion of the training data and includes the <sos>, <eos> and <pad> tokens.
The input of the model is restricted to sequences of length up to 34, where to the token of the sentence we prepend the <sos> token and append the <eos> token.
The tokens for each batch are further appended to the same length via the <pad> token.
To optimize the weights of the model, the AdamW optimizer is used with default (0.01) weight decay, and each model is trained for two epochs with a batch size of 8.
We use a stochastic gradient descent optimizer for the nodes x .
Here are the hyperparameter ranges and best values used for each model:
For BP : β θ ∈ { 0 . 0004 , 0 .
Best value: 0 . 0016 .
For PC F : T ∈ { 4 , 5 , 6 , 7 , 8 } , β ϕ ∈ { 0 . 001953125 , 0 . 00390625 , 0 . 0078125 , 0 . 015625 , 0 . 03125 } , β θ ∈ { 0 . 0002 , 0 .
Best values: T = 4 , β ϕ = 0 .
015625 , β θ = 0 .
For PC F KL : T ∈ { 4 , 5 , 6 , 7 , 8 } , β ϕ ∈ {
0 } , β θ ∈ { 0 . 000025 , 0 . 00005 , 0 . 0001 , 0 . 0002 , 0 . 0004 , 0 . 0008 , 0 .} .
Best values
: T
=
, β
ϕ
= 0 .
5 , β θ = 0 .
The total training time of the hyperparameter search is approximately 94 hours on one Nvidia Titan
RTX GPU. E.3.1 Qualitative Results Table 2 shows example sentence completions given by BP , PC F , and PC F KL along with the probabilities assigned to each prediction. The sentences were selected subjectively from the test dataset based on how interesting they are and cut right before a subjectively interesting word to be predicted.
[Table]
Yet the bank and its executives are still ready to support specific Democratic [candidates]
[Table]
[Table]
candidates
[Table]
candidates
[Table]
and
[Table]
[Table]
presidential
[Table]
[Table]
GMAC started out offering car [loans] and
[Table]
[Table]
[Table]
[Table]
[Table]
sales
[Table] 4) sales [Table] 7) and (
[Table]
[Table]
products
[Table]
[Table]
[Table]
[Table]
in
[Table]
services (
[Table]
I’ve been dreaming about this since I was a [child] great
[Table]
lot
[Table]
[Table]
[Table]
good
[Table]
very
[Table]
year
[Table]
Here is a breakdown of the seven taxes and fees that have been [collected] a
[Table] [Table] a (4.7) a ( [Table]
3) to (2.0) the (
[Table]
3) to (
[Table]
6) in (
[Table]
9) in (1.3) the (2.4)
Under the plan, Iceland will reimburse the [money] first ( [Table] 9) best ( [Table]
7) first (
[Table]
.9) world (
[Table]
[Table]
) first
[Table]
) same (
[Table]
2) same (
[Table]
most (0.7) world (1.2)
Aniston and Pitt were still married when Pitt and Jolie made the 2005 [film] , (2.3) , (23.0) .
(1.9) and (5.6) , (10.0) World (1.6) .
(5.1) and (3.9)