D EEP LEARNING VIA MESSAGE PASSING ALGORITHMS BASED ON BELIEF PROPAGATION
Anonymous authors
Paper under double-blind review
A BSTRACT
Message-passing algorithms based on the Belief Propagation (BP) equations constitute a well-known distributed computational scheme.
They yield exact marginals on tree-like graphical models and have also proven to be effective in many problems deﬁned on loopy graphs, from inference to optimization, from signal processing to clustering.
The
BP-based schemes are fundamentally different from stochastic gradient descent (SGD), on which the current success of deep networks is based.
In this paper, we present and adapt to mini-batch training on GPUs a family of
BP based message passing algorithms with a reinforcement term that biases distributions towards locally entropic solutions.
These algorithms are capable of training multi-layer neural networks with performance comparable to SGD heuristics in a diverse set of experiments on natural datasets including multi-class image classiﬁcation and continual learning, while being capable of yielding improved performances on sparse networks.
Furthermore, they allow to make approximate
Bayesian predictions that have higher accuracy than point-wise ones.
I NTRODUCTION
Belief Propagation is a method for computing marginals and entropies in probabilistic inference problems (Bethe, 1935; Peierls, 1936; Gallager, 1962; Pearl, 1982).
These include optimization problems as well once they are written as zero temperature limit of a Gibbs distribution that uses the cost function as energy.
Learning is one particular case, in which one wants to minimize a cost which is a data dependent loss function.
These problems are generally intractable and message-passing techniques have been particularly successful at providing principled approximations through efﬁcient distributed computations.
A particularly compact representation of inference/optimization problems that is used to build massage-passing algorithms is provided by factor graphs.
A factor graph is a bipartite graph composed of variables nodes and factor nodes expressing the interactions among variables.
Belief Propagation is exact for tree-like factor graphs (Yedidia et al., 2003)), where the Gibbs distribution is naturally factorized, whereas it is approximate for graphs with loops.
Still, loopy BP is routinely used with success in many real world applications ranging from error correcting codes, vision, clustering, just to mention a few.
In all these problems, loops are indeed present in the factor graph and yet the variables are weakly correlated at long range and BP gives good results.
A ﬁeld in which BP has a long history is the statistical physics of disordered systems where it is known as Cavity Method (Mézard et al., 1987).
It has been used to study the typical properties of spin glass models which represent binary variables interacting through random interactions over a given graph.
It is very well known that in spin glass models deﬁned on complete graphs and in locally tree-like random graphs, which are both loopy, the weak correlation conditions between variables may hold and BP give asymptotic exact results (Mézard & Montanari, 2009).
Here we will mostly focus on neural networks ± 1 binary weights and sign activation functions, for which the messages and the marginals can be described simply by the difference between the probabilities associated with the +1 and -1 states, the so called magnetizations .
The effectiveness of BP for deep learning has never been numerically tested in a systematic way, however there is clear evidence that the weak correlation decay condition does not hold and thus BP convergence and approximation quality is unpredictable.
In this paper we explore the effectiveness of a variant of BP that has shown excellent convergence properties in hard optimization problems and in non-convex shallow networks.
It goes under the name of focusing BP (fBP) and is based on a probability distribution, a likelihood, that focuses on highly entropic wide minima, neglecting the contribution to marginals from narrow minima even when they are the majority (and hence dominate the Gibbs distribution).
This version of BP is thus expected to give good results only in models that have such wide entropic minima as part of their energy landscape.
As discussed in (Baldassi et al., 2016a), a simple way to deﬁne fBP is to add a "reinforcement" term to the BP equations: an iteration-dependent local ﬁeld is introduced for each variable, with an intensity proportional to its marginal probability computed in the previous iteration step.
This ﬁeld is gradually increased until the entire system becomes fully biased on a conﬁguration.
The ﬁrst version of reinforced BP was introduced in (Braunstein & Zecchina, 2006) as a heuristic algorithm to solve the learning problem in shallow binary networks.
Baldassi et al.
(2016a) showed that this version of BP is a limiting case of fBP, i.e., BP equations written for a likelihood that uses the local entropy function instead of the error (energy) loss function.
As discussed in depth in that study, one way to introduce a likelihood that focuses on highly entropic regions is to create y coupled replicas of the original system.
fBP equations are obtained as BP equations for the replicated system.
It turns out that the fBP equations are identical to the BP equations for the original system with the only addition of a self-reinforcing term in the message passing scheme.
The fBP algorithm can be used as a solver by gradually increasing the effect of the reinforcement: one can control the size of the regions over which the fBP equations estimate the marginals by tuning the parameters that appear in the expression of the reinforcement, until the high entropy regions reduce to a single conﬁguration.
Interestingly, by keeping the size of the high entropy region ﬁxed, the fBP ﬁxed point allows one to estimate the marginals and entropy relative to the region.
In this work, we present and adapt to GPU computation a family of fBP inspired message passing algorithms that are capable of training multi-layer neural networks with generalization performance and computational speed comparable to SGD.
This is the ﬁrst work that shows that learning by message passing in deep neural networks 1) is possible and 2) is a viable alternative to SGD.
Our version of fBP adds the reinforcement term at each mini-batch step in what we call the Posterioras-Prior (PasP) rule.
Furthermore, using the message-passing algorithm not as a solver but as an estimator of marginals allows us to make locally Bayesian predictions, averaging the predictions over the approximate posterior.
The resulting generalization error is signiﬁcantly better than those of the solver, showing that, although approximate, the marginals of the weights estimated by messagepassing retain useful information.
Consistently with the assumptions underlying fBP, we ﬁnd that the solutions provided by the message passing algorithms belong to ﬂat entropic regions of the loss landscape and have good performance in continual learning tasks and on sparse networks as well.
We also remark that our PasP update scheme is of independent interest and can be combined with different posterior approximation techniques.
The paper is structured as follows: in Sec.
2 we give a brief review of some related works.
In Sec.we provide a detailed description of the message-passing equations and of the high level structure of the algorithms.
In Sec.
4 we compare the performance of the message passing algorithms versus
SGD based approaches in different learning settings.
R ELATED W ORKS
The literature on message passing algorithms is extensive, we refer to Mézard & Montanari (2009) and Zdeborová & Krzakala (2016) for a general overview.
More related to our work, multilayer message-passing algorithms have been developed in inference contexts (Manoel et al., 2017; Fletcher et al., 2018), where they have been shown to produce exact marginals under certain statistical assumptions on (unlearned) weight matrices.
The properties of message-passing for learning shallow neural networks have been extensively studied (see Baldassi et al.
and reference therein).
Barbier et al.
(2019) rigorously show that message passing algorithms in generalized linear models perform asymptotically exact inference under some statistical assumptions.
Dictionary learning and matrix factorization are harder problems closely related to deep network learning problems, in particular to the modelling of a single intermediate layer.
They have been approached using message passing in Kabashima et al.
(2016) and Parker et al.
(2014), although the resulting predictions are found to be asymptotically inexact (Maillard et al., 2021).
The same problem is faced by the message passing algorithm recently proposed for a multi-layer matrix factorization scenario (Zou et al., 2021).
Unfortunately, our framework as well doesn’t yield asymptotic exact predictions.
Nonetheless, it gives a message passing heuristic that for the ﬁrst time is able to train deep neural networks on natural datasets, therefore sets a reference for the algorithmic applications of this research line.
A few papers advocate the success of SGD to the geometrical structure (smoothness and ﬂatness) of the loss landscape in neural networks (Baldassi et al., 2015; Chaudhari et al., 2017; Garipov et al., 2018;
Li et al., 2018;
Pittorino et al., 2021;
Feng & Tu, 2021).
These considerations do not depend on the particular form of the SGD dynamics and should extend also to other types of algorithms, although
SGD is by far the most popular choice among NNs practitioners due to its simplicity, ﬂexibility, speed, and generalization performance.
While our work focuses on message passing schemes, some of the ideas presented here, such as the PasP rule, can be combined with algorithms for Bayesian neural networks’ training (HernándezLobato & Adams, 2015; Wu et al., 2018).
Recent work extends BP by combining it with graph neural networks (Kuck et al., 2020; Satorras & Welling, 2021).
Finally, some work in computational neuroscience shows similarities to our approach (Rao, 2007).
L EARNING BY MESSAGE PASSING 3. P OSTERIOR - AS -P RIOR UPDATES
We consider a multi-layer perceptron with L hidden neuron layers, having weight and bias parameters
W = { W (cid:96) , b (cid:96) } L(cid:96)
=0 .
We allow for stochastic activations P (cid:96) ( x (cid:96) +1 | z (cid:96) ) , where z (cid:96) is the neuron’s preactivation vector for layer (cid:96) , and P (cid:96) is assumed to be factorized over the neurons.
If no stochasticity is present, P (cid:96) just encodes an element-wise activation function.
The probability of output y given an input x is then given by
[Equation]
where for convenience we deﬁned x 0 = x and x L +1 =
y .
In a Bayesian framework, given a training set D = { ( x n , y n ) } n and a prior distribution over the weights q θ ( W ) in some parametric family, the posterior distribution is given by
[Equation]
Here ∝ denotes equality up to a normalization factor.
Using the posterior one can compute the Bayesian prediction for a new data-point x through the average P ( y | x , D, θ ) =
(cid:82) d W P ( y | x , W ) P ( W | D, θ ) .
Unfortunately, the posterior is generically intractable due to the hard-to-compute normalization factor.
On the other hand, we are mainly interested in training a distribution that covers wide minima of the loss landscape that generalize well (Baldassi et al., 2016a) and in recovering pointwise estimators within these regions.
The Bayesian modeling becomes an auxiliary tool to set the stage for the message passing algorithms seeking ﬂat minima.
We also need a formalism that allows for mini-batch training to speed-up the computation and deal with large datasets.
Therefore, we devise an update scheme that we call Posterior-as-Prior (PasP), where we evolve the parameters θ t of a distribution q θ t ( W ) computed as an approximate mini-batch posterior, in such a way that the outcome of the previous iteration becomes the prior in the following step.
In the PasP scheme, θ t retains the memory of past observations.
We also add an exponential factor ρ , that we typically set close to 1, tuning the forgetting rate and playing a role similar to the learning rate in SGD.
Given a mini-batch ( X t , y t ) sampled from the training set at time t and a scalar ρ > 0 , the PasP update reads
[Equation]
where ≈ denotes approximate equality and we do not account for the normalization factor.
A ﬁrst approximation may be needed in the computation of the posterior, a second to project the approximate posterior onto the distribution manifold spanned by θ (Minka, 2001).
In practice, we will consider factorized approximate posterior in an exponential family and priors q θ in the same family, although
Eq.
3 generically allow for more reﬁned approximations.
Notice that setting ρ = 1 , the batch-size to 1, and taking a single pass over the dataset, we recover the Assumed Density Filtering algorithm (Minka, 2001).
For large enough ρ (including ρ = 1 ), the iterations of q θ t will concentrate on a pointwise estimator.
This mechanism mimics the reinforcement heuristic commonly used to turn Belief Propagation into a solver for constrained satisfaction problems (Braunstein & Zecchina, 2006) and related to ﬂat-minima discovery (see focusing-BP in
Baldassi et al.
(2016a)).
A different prior updating mechanism which can be understood as empirical
Bayes has been used in Baldassi et al.
(2016b).
3. I NNER MESSAGE PASSING LOOP
While the PasP rule takes care of the reinforcement heuristic across mini-batches, we compute the mini-batch posterior in Eq.
3 using message passing approaches derived from Belief Propagation.
BP is an iterative scheme for computing marginals and entropies of statistical models Mézard &
Montanari (2009).
It is most conveniently expressed on factor graphs, that is bipartite graphs where the two sets of nodes are called variable nodes and factor nodes.
They respectively represent the variables involved in the statistical model and their interactions.
Message from factor nodes to variable nodes and viceversa are exchanged along the edges of the factor graph for a certain number of BP iterations or until a ﬁxed point is reached.
The factor graph for P ( W | X t , y t , θ t ) can be derived from Eq. 2, with the following additional speciﬁcations.
For simplicity, we will ignore the bias term in each layer.
We assume factorized q θ t ( W ) , each factor parameterized by its ﬁrst two moments.
In what follows, we drop the PasP iteration index t .
For each example ( x n , y n ) in the mini-batch, we introduce the auxiliary variables x (cid:96)n , (cid:96) = 1 , . . .
, L , representing the layers’ activations.
For each example, each neuron in the network contributes a factor node to the factor graph.
The scalar components of the weight matrices and the activation vectors become variable nodes.
This construction is presented in Appendix A, where we also derive the message update rules on the factor graph.
The factor graph thus deﬁned is extremely loopy and straightforward iteration of BP has convergence issues.
Moreover, in presence of a homogeneous prior over the weights, the neuron permutation symmetry in each hidden layer induces a strongly attractive symmetric ﬁxed point that hinders learning.
We work around these issues by breaking the symmetry at time t = 0 with an inhomogeneous prior.
In our experiments a little initial heterogeneity is sufﬁcient to obtain specialized neurons at each following time step.
Additionally, we do not require message passing convergence in the inner loop (see Algorithm 1) but perform one or a few iterations for each θ update.
We also include an inertia term commonly called damping factor in the message updates (see B.2).
As we shall discuss, these simple rules sufﬁce to train deep networks by message passing.
For the inner loop we adapt to deep neural networks four different message passing algorithms, all of which are well known to the literature although derived in simpler settings: Belief Propagation (BP),
BP-Inspired (BPI) message passing, mean-ﬁeld (MF), and approximate message passing (AMP).
The last three algorithms can be considered approximations of the ﬁrst one.
In the following paragraphs we will discuss their common traits, present the BP updates as an example, and refer to Appendix A for an in-depth exposition.
For all algorithms, message updates can be divided in a forward pass and backward pass, as also done in (Fletcher et al., 2018) in a multi-layer inference setting.
The BP algorithm is compactly reported in Algorithm 1.
Meaning of messages.
All the messages involved in the message passing can be understood in terms of cavity marginals or full marginals (as mentioned in the introduction BP is also known as
Cavity Method, see (Mézard & Montanari, 2009)).
Of particular relevance are m (cid:96)ki and σ (cid:96)ki , denoting the mean and variance of the weights W (cid:96) ki .
The quantities ˆ x (cid:96)in and ∆ (cid:96)in instead denote the mean and variance of the i -th neuron’s a
Scalar free energies.
All message passing schemes are conveniently expressed in terms of two functions that correspond to the effective free energy (Zdeborová & Krzakala, 2016) of a single neuron and of a single weight respectively :
[Equation]
Notice that for common deterministic activations such as ReLU and sign , the function ϕ has analytic and smooth expressions (see Appendix A.8).
The same holds for the function ψ when q θ ( w ) is
Gaussian (continuous weights) or a mixture of atoms (discrete weights).
At the last layer we impose
P L +1 ( y | z )
=
I ( y = sign( z )) in binary classiﬁcation tasks and P L +
( y | z )
=
I ( y = arg max( z )) in multi-class classiﬁcation (see Appendix A.9).
While in our experiments we use hard constraints for the ﬁnal output, therefore solving a constraint satisfaction problem, it would be interesting to also consider soft constraints and introduce a temperature, but this is beyond the scope of our work.
Start and end of message passing.
At the beginning of a new PasP iteration t , we reset the messages (see Appendix A) and run message passing for τ max iterations.
We then compute the new prior’s parameters θ t +1 from the posterior given by the message passing.
BP Forward pass.
After initialization of the messages at time τ = 0 , for each following time we propagate a set of message from the ﬁrst to the last layer and then another set from the last to the ﬁrst.
For an intermediate layer (cid:96) the forward pass reads
[Equation]
The equations for the ﬁrst layer differ slightly and in an intuitive way from the ones above (see
Appendix A.3).
BP Backward pass.
The backward pass updates a set of messages from the last to the ﬁrst layer:
[Equation]
As with the forward pass [Equation] we add the caveat that for the last layer the equations are slightly different from the ones above
[Equation]
Computational complexity The message passing equations boil down to element-wise operations and tensor contractions that we easily implement using the GPU friendly julia library Tullio.jl (Abbott et al., 2021).
For a layer of input and output size N and considering a batch-size of B , the time complexity of a forth-and-back iteration is O ( N 2 B ) for all message passing algorithms (BP, BPI, MF, and AMP), the same as SGD.
The prefactor varies and it is generally larger than SGD (see Appendix
B.10).
Also, time complexity for message passing is proportional to τ max (which we typically set to 1).
We provide our implementation in the GitHub repo anonymous .
Algorithm
// Message passing used in the PasP Eq.
3 to approximate.
// the mini-batch posterior.
// Here we specifically refer to BP updates.
// BPI, MF, and AMP updates take the same form but using // the rules in Appendix A.4, A.5, and A.7 respectively 1 Initialize messages. 2 for τ = 1 , . . .
τ max do // Forward Pass for l = 0 , . . .
, L do compute ˆ x (cid:96) , ∆ (cid:96) using (6, 7) compute m (cid:96) , σ (cid:96) using (8, 9) compute V (cid:96) , ω (cid:96) using (10, 11) // Backward Pass for l = L, . . . , 0 do compute g (cid:96) , Γ (cid:96) using (12, 13) compute A (cid:96) , B (cid:96) using (14, 15) compute G (cid:96) , H (cid:96) using (16, 17)
N UMERICAL RESULTS
We implement our message passing algorithms on neural networks with continuous and binary weights and with binary activations.
In our experiments we ﬁx τ max = 1 .
We typically do not observe an increase in performance taking more steps, except for some speciﬁc cases and in particular for MF layers.
We remark that for τ max = 1 the BP and the BPI equations are identical, so in most of the subsequent numerical results we will only investigate BP.
We compare our algorithms with a SGD-based algorithm adapted to binary architectures (Hubara et al., 2016) which we call BinaryNet along the paper (see Appendix B.6 for details).
Comparison of Bayesian predictions are with the gradient-based Expectation Backpropagation (EBP) algorithm (Soudry et al., 2014a), also able to deal with discrete weights and activations.
In all architectures we avoid the use of bias terms and batch-normalization layers.
We ﬁnd that message-passing algorithms are able to train generic MLP architectures with varying numbers and sizes of hidden layers.
As for the datasets, we are able to perform both binary classiﬁcation and multi-class classiﬁcation on standard computer vision datasets such as MNIST, Fashion-MNIST, and CIFAR-10.
Since these datasets consist of 10 classes, for the binary classiﬁcation task we divide each dataset in two classes (even vs odd).
We report that message passing algorithms are able to solve these optimization problems with generalization performance comparable to or better than SGD-based algorithms.
When the test error is on-par, the training error is usually lower for message passing schemes, suggesting that these algorithms are able to achieve higher capacity than SGD-based algorithms (given the same test error). We outline performances superior to SGD in the continual learning setting and when training sparse networks.
Timings of our GPU implementations of message passing algorithms are competitive with SGD (see Appendix B.10).
4. E XPERIMENTS ACROSS ARCHITECTURES
We select a speciﬁc task, multi-class classiﬁcation on Fashion-MNIST, and we compare the message passing algorithms with BinaryNet for different choices of the architecture (i.e. we vary the number and the size of the hidden layers).
In Fig.1 (Left) we present the learning curves for a MLP with 3 hidden layers with 501 units with binary weights and activations.
Similar results hold in our experiments with 2 or 3 hidden layers of 101, 501 or 1001 units and with batch sizes from 1 to from 1024.
The parameters used in our simulations are reported in Appendix B.3.
Results on networks with continuous weights can be found in Fig.2 (Right).
4. S PARSE LAYERS
Since the BP algorithm has notoriously been successful on sparse graphs, we perform a straightforward implementation of pruning at initialization, i.e. we impose a random boolean mask on the weights that we keep ﬁxed along the training.
We call sparsity the fraction of zeroed weights.
This kind of non-adaptive pruning is known to largely hinder learning (Frankle et al., 2021; Sung et al., 2021).
In the right panel of Fig. 1, we report results on sparse binary networks in which we train a MLP with 2 hidden layers of 101 units on the MNIST dataset.
For reference, results on pruning quantized/binary networks can be found in Refs. (Han et al., 2016; Ardakani et al., 2017; Tung & Mori, 2018; Diffenderfer & Kailkhura, 2021).
Experimenting with sparsity up to 90%, we observe that BP and MF perform better than BinaryNet.
AMP struggles behind BinaryNet instead.
[Figure]
4. E XPERIMENTS ACROSS DATASETS
We now ﬁx the architecture, a MLP with 2 hidden layers of 501 neurons each with binary weights and activations. We vary the dataset, i.e. we test the BP-based algorithms on standard computer vision benchmark datasets such as MNIST, Fashion-MNIST and CIFAR-10, in both the multi-class and binary classiﬁcation tasks.
In Tab. 1 we report the ﬁnal test errors obtained by the message passing algorithms compared to the BinaryNet baseline.
See Appendix B.4 for the corresponding training errors and the parameters used in the simulations.
We mention that while the test performance is mostly comparable, the train error tends to be lower for the message passing algorithms. [Table]
4. L OCALLY B AYESIAN ERROR
The message passing framework used as an estimator of the mini-batch posterior marginals allows us to perform approximate Bayesian prediction, i [Table] e. averaging the pointwise predictions over the approximate posterior.
We observe better generalization error from Bayesian predictions compared to point-wise ones
[Table]
showing that the marginals retain useful information. However, we roughly estimate the marginals with the PasP mini-batch procedure (the exact ones should be computed with a full-batch procedure, but this converges with difﬁculty in our tests).
Since BP-based algorithms tend to focus on dense states (as also conﬁrmed by the local energy measure performed in Appendix B.5)
[Table]
the Bayesian error we compute can be considered as a local approximation of the full one.
We report results for binary classiﬁcation on the MNIST dataset in Fig. 2, and we observe the same performance increase on different datasets and architectures.
We obtain the Bayesian prediction from the output marginal given by a single forward pass of the message passing.
To obtain good Bayesian estimates it is important that the posterior distribution does not concentrate too much, otherwise the Bayesian prediction will converge to the prediction of a single conﬁguration.
In Fig.2 we also perform a comparison of BP (point-wise and Bayesian) with SGD and another algorithm able to perform Bayesian predictions, Expectation Backpropagation (Soudry et al., 2014a) see Appendix B.7 for implementation details.
[Figure]
4. C ONTINUAL LEARNING
Given the high local entropy (i.e. the ﬂatness) of the solutions found by the BP-based algorithms (see Appendix B.5), we perform additional tests in a classic setting, continual learning, where the possibility of locally rearranging the solutions while keeping low training error can be an advantage.
When a deep network is trained sequentially on different tasks, it tends to forget exponentially fast previously seen tasks while learning new ones (McCloskey & Cohen, 1989; Robins, 1995; Fusi et al., 2005).
Recent work (Feng & Tu, 2021) has shown that searching for a ﬂat region in the loss landscape can indeed help to prevent catastrophic forgetting.
Several heuristics have been proposed to mitigate the problem (Kirkpatrick et al., 2017; Aljundi et al., 2018; Zenke et al., 2017; Laborieux et al., 2021) but all require specialized adjustments to the loss or the dynamics .
Here we show instead that our message passing schemes are naturally prone to learn multiple tasks sequentially, mitigating the characteristic memory issues of the gradient-based schemes without the need for explicit modiﬁcations.
As a prototypical experiment, we sequentially trained a multi-layer neural network on 6 different versions of the MNIST dataset, where the pixels of the images have been randomly permuted (Goodfellow et al., 2013), giving a ﬁxed budget of 40 epochs on each task.
We present the results for a two hidden layer neural network with 2001 units on each layer (see
Appendix B.3 for details).
As can be seen in Fig.
3, at the end of the training the BP algorithm is able to reach good generalization performances on all the tasks.
We compared the BP performance with
BinaryNet, which already performs better than SGD with continuous weights (see the discussion in Laborieux et al.
While our BP implementation is not competitive with ad-hoc techniques speciﬁcally designed for this problem, it beats non-specialized heuristics.
Moreover, we believe that specialized approaches like the one of Laborieux et al.
(2021) can be adapted to message passing as well.
[Figure]
D ISCUSSION AND CONCLUSIONS
While successful in many ﬁelds, message passing algorithms, have notoriously struggled to scale to deep neural networks training problems.
Here we have developed a class of fBP-based message passing algorithms and used them within an update scheme, Posterior-as-Prior (PasP), that makes it possible to train deep and wide multilayer perceptrons by message passing.
We performed experiments binary activations and either binary or continuous weights.
Future work should try to include different activations, biases, batch-normalization, and convolutional layers as well.
Another interesting direction is the algorithmic computation of the (local) entropy of the model from the messages.
Further theoretical work is needed for a more complete understanding of the robustness of our methods.
Recent developments in message passing algorithms (Rangan et al., 2019) and related theoretical analysis (Goldt et al., 2020) could provide fruitful inspirations.
While our algorithms can be used for approximate Bayesian inference, exact posterior calculation is still out of reach for message passing approaches and much technical work is needed in that direction.
A CKNOWLEDGMENTS
We thank anonymous for useful discussions on the numerical implementation of the BP equations.
Appendices C ONTENTS
A BP-based message passing algorithms
A.1 Preliminary considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.2 Derivation of the BP equations . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.3 BP equations . .
A.4 BPI equations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.5 MF equations . .
A.6 Derivation of the AMP equations . . . . . . . . . . . . . . . . . . . . . . . . . . .
A.7 AMP equations .
A.8 Activation Functions . .
A.9 The ArgMax layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
B Experimental details
B.1 Hyper-parameters of the BP-based scheme . . . . . . . . . . . . . . . . . . . . . .
B.2 Damping scheme for the message passing . . . . . . . . . . . . . . . . . . . . . .
B.3 Architectures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .[-B.
-]
[Table] Varying [Table]
[Table] energy
[Table] BinaryNet [Table] [Table]
[Table]
[Table]
A BP- BASED MESSAGE PASSING ALGORITHMS A. P RELIMINARY CONSIDERATIONS
Given a mini-batch B = { ( x n , y n ) } n , the factor graph deﬁned by Eqs.
(1, 2, 18) is explicitly written as:
P
[Equation]
W
[Equation]
| B , θ ) ∝
[Equation]
(cid:32) x
[Equation]
(cid:12)(cid:12)(cid:12)(cid:12)
[Equation]
i
W (cid:96)ki [Equation] (cid:33) (cid:89) k,i,(cid:96) q θ ( W (cid:96)ki ) , (18) where x 0 n = x n , x L +1 n = y n .
The derivation of the BP equations for this model is straightforward albeit lengthy and involved.
It is obtained following the steps presented in multiple papers, books, and reviews, see for instance (Mézard & Montanari, 2009; Zdeborová & Krzakala, 2016; Mézard, 2017), although it has not been attempted before in deep neural networks.
It should be noted that a (common) approximation that we take here with respect to the standard BP scheme, is that messages are assumed to be Gaussian distributed and therefore parameterized by their mean and variance.
This goes by the name of relaxed belied propagation (rBP), just referred to as BP throughout the paper.
We derive the BP equations in A.2 and present them all together in A.3.
From BP, we derive othermessage passing algorithms useful for the deep network training setting, all of which are well known to the literature: BP-Inspired (BPI) message passing A.4, mean-ﬁeld (MF) A.5, and approximate message passing (AMP) A.7.
The AMP derivation is the more involved and given in A.6.
In all these cases, message updates can be divided in a forward pass and a backward pass, as also done in Fletcher et al.
(2018) in a multi-layer inference setting.
The BP algorithm is compactly reported in Algorithm 1.
In our notation, (cid:96) denotes the layer index, τ the BP iteration index, k an output neuron index, i an input neuron index, and n a sample index.
We report below, for convenience, some of the considerations also present in the main text.
Meaning of messages.
All the messages involved in the message passing equations can be understood in terms of cavity marginals or full marginals (as mentioned in the introduction BP is also known as the Cavity Method, see Mézard & Montanari (2009)).
Of particular relevance are the quantities m (cid:96)ki and σ (cid:96)ki , denoting the mean and variance of the weights W (cid:96)ki .
The quantities ˆ x (cid:96)in and ∆ (cid:96)in instead denote mean and variance of the i -th neuron’s activation in layer (cid:96) in correspondence of an input x n .
Scalar free energies.
All message passing schemes can be expressed using the following scalar functions, corresponding to single neuron and single weight effective free-energies respectively:
[Equation]
These free energies will naturally arise in the derivation of the BP equations in Appendix A.2.
For the last layer, the neuron function has to be slightly modiﬁed:
[Equation] [Equation] Notice that for common deterministic activations such as ReLU and sign , the function ϕ has analytic and smooth expressions that we give in Appendix A.8.
Same goes for ψ when q θ ( w ) is Gaussian (continuous weights) or a mixture of atoms (discrete weights).
At the last layer we impose P L +1 ( y | z )
=
I ( y = sign( z )) in binary classiﬁcation [-tasks and P L +
-]tasks.
For multi-class classiﬁcation instead, we have to adapt the formalism to vectorial pre-activations z and assume
P L +1 ( y | z )
=
I ( y = arg max( z )) (see Appendix A.9).
While in our experiments we use hard constraints for the ﬁnal output, therefore solving a constraint satisfaction problem, it would be interesting to also consider generic loss functions. That would require minimal changes to our formalism, but this is beyond the scope of our work.
Binary weights.
In our experiments we use ± 1 weights in each layer.
Therefore each marginal can be parameterized by a single number and our prior/posterior takes the form
[Equation]
The effective free energy function Eq.
20 becomes
[Equation]
(23) and the messages G can be dropped from the message passing.
Start and end of message passing.
At the beginning of a new PasP iteration t , we reset the messages to zero and run message passing for τ max iterations.
We then compute the new prior q θ t +1 ( W ) from the posterior given by the message passing iterations.
A. D ERIVATION OF THE BP EQUATIONS
In order to derive the BP equations, we start with the following portion of the factor graph reported in
Eq.
18 in the main text, describing the contribution of a single data example in the inner loop of the
PasP updates:
[Equation]
where x 0 n = x n , x L +1 n = y n
[Equation]
[Equation]
where we recall that the quantity x (cid:96)kn corresponds to the activation of neuron k in layer (cid:96) in correspondence of the input example n .
Let us start by analyzing the single factor:
[Equation]
We refer to messages that travel from input to output in the factor graph as upgoing or upwards messages, while to the ones that travel from output to input as downgoing or backwards messages.
Factor-to-variable- W messages The factor-to-variable- W messages read:
[Equation]
[Table]
[Equation] [Table] [Equation] where ν ↓ denotes the messages travelling downwards (from output to input) in the factor graph
[Equation] We denote the means and variances of the incoming messages respectively with m (cid:96)ki → n , ˆ x (cid:96)in → k and σ (cid:96)ki → n , ∆ (cid:96)in → k :
[Equation]
We now use the central limit theorem to observe that with respect to the incoming messages distributions - assuming independence of these messages - in the large input limit the preactivation is a
Gaussian random variable:
[Equation]
[Equation]
where:
[Equation]
Therefore we can rewrite the outgoing messages as:
[Equation]
We now assume W (cid:96)ki x (cid:96)in to be small compared to the other terms.
With a second order Taylor expansion we obtain:
[Equation]
Introducing now the function:
[Equation]
and deﬁning:
[Equation]
the expansion for the log-message reads:
[Equation]
[Equation]
Factor-to-variable- x messages The derivation of these messages is analogous to the factor-tovariable- W ones in Eq.
26 just reported.
The ﬁnal result for the log-message is:
[Equation]
[Equation]
Variable- W -to-output-factor messages The message from variable W (cid:96)ki to the output factor kn reads:
[Equation]
[Equation]
where we have deﬁned:
[Equation]
Introducing now the effective free energy:
[Equation]
we can express the ﬁrst two cumulants of the message ν (cid:96)ki → n ( W (cid:96)ki ) as:
[Equation]
Variable- x -to-input-factor messages We can write the downgoing message as:
[Equation]
where:
[Equation]
Variable- x -to-output-factor messages By deﬁning the following cavity quantities:
[Equation]
and the following non-cavity ones:
[Equation]
we can express the ﬁrst 2 cumulants of the upgoing messages as:
[Equation]
[Equation]
Wrapping it up Additional but straightforward considerations are required for the ﬁnal input and output layers ( (cid:96) =
and (cid:96) =
L respectively), since they do not receive messages from below and above respectively.
In the end, thanks to independence assumptions and the central limit theorem that we used throughout the derivations, we arrive to a closed set of equations involving the means and the variances (or otherwise the corresponding natural parameters) of the messages.
Within the same approximation assumption, we also replace the cavity quantities corresponding to variances with the non-cavity counterparts.
Dividing the update equations in a forward and backward pass, and ordering them using time indexes in such a way that we have an efﬁcient ﬂow of information, we obtain the set of BP equations presented in the main text Eqs.
(6-17) and in the Appendix Eqs.
A. BP EQUATIONS
We report here the end result of the derivation in last section, the complete set of BP equations also presented in the main text as Eqs.
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Equation]
In these equations for simplicity we abused the notation
[Equation]
in fact for the ﬁrst layer ˆ x (cid:96) =0 ,τ n is ﬁxed and given by the input x n while ∆ (cid:96) =0 ,τ n = 0 instead.
Backward Pass For τ = 1 , . .
, τ max , for (cid:96) =
L, . .
[Equation]
[Equation]
In these equations as well we abused the notation: calling L the number of hidden neuron layers, when (cid:96) =
L one should use ϕ L +1 ( y, ω, V ) from Eq.
21 instead of ϕ L +1 ( B, A, ω, V ) .
A. BPI EQUATIONS
The BP-Inspired algorithm (BPI) is obtained as an approximation of BP replacing some cavity quantities with their non-cavity counterparts.
What we obtain is a generalization of the single layer algorithm of Baldassi et al.
[Equation]
[Equation]
A. MF EQUATIONS
The mean-ﬁeld (MF) equations are obtained as a further simpliﬁcation of BPI, using only non-cavity quantities.
Although the simpliﬁcation appears minimal at this point, we empirically observe a non-negligible discrepancy between the two algorithms in terms of generalization performance and computational time.
Forward pass.
[Equation]
Backward pass
[Equation]
A. D ERIVATION OF THE AMP EQUATIONS
In order to obtain the AMP equations
[Equation]
we approximate cavity quantities with non-cavity ones in the
BP equations Eqs.
(60-71) using a ﬁrst order expansion.
We start with the mean activation:
[Equation]
Analogously, for the weight’s mean we have:
[Equation]
This brings us to:
[Equation]
Let us now apply the same procedure to the other set of cavity messages:
[Equation]
[Table]
We are now able to write down the full AMP equations, that we present in the next section
[Table]
A. AMP EQUATIONS
In summary
[Table]
in the last section we derived the AMP algorithm as a closure of the BP messages passing over non-cavity quantities, relying on some statistical assumptions on messages and interactions.
With respect to the MF message passing, we ﬁnd some additional terms that go under the name of
Onsager corrections.
In-depth overviews of the AMP (also known as Thouless-Anderson-Palmer (TAP)) approach can be found in Refs.
(Zdeborová & Krzakala, 2016; Mézard, 2017; Gabrié, 2020).
The ﬁnal form of the AMP equations for the multi-layer perceptron is given below.
Initialization At τ = 0 :
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
[Equation]
Forward Pass
At each τ = 1 , . . .
, τ max , for (cid:96) = 0 , . . .
, L :
[Equation]
[Equation] [Equation] [Equation] [Equation]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
[Table]
[Equation]
A. A CTIVATION F UNCTIONS A.8. S IGN
In most of our experiments we use sign activations in each layer.
With this choice, the neuron’s free energy 19 takes the form
[Equation]
where
[Equation]
Notice that for sign activations the messages A can be dropped.
A.8. R E LU
For ReLU ( x ) = max(0 , x ) activations the free energy 19 becomes
[Equation]
[Equation]
where
[Equation]
A. T HE A RG M AX LAYER
In order to perform multi-class classiﬁcation, we have to perform an argmax operation on the last layer of the neural network.
Call z k , for k = 1 , . . .
, K , the Gaussian random variables output of the last layer of the network in correspondence of some input x .
Assuming the correct label is class k ∗ , the effective partition function Z k ∗ corresponding to the output constraint reads: [Figure]
[Equation]
Here Θ( x ) is the Heaviside indicator function and we used the deﬁnition of H from Eq.
The integral on the last line cannot be expressed analytically, therefore we have to resort to approximations.
A.9. A PPROACH 1: J ENSEN I NEQUALITY
Using the Jensen inequality we obtain:
[Equation]
Reparameterizing the expectation we have:
[Equation]
The derivative ∂ ω k ˜ φ k ∗ and ∂ 2 ω k ˜
φ
k ∗ that we need can then be estimated by sampling (once) (cid:15) :
[Equation]
where we have deﬁned:
[Equation]
A.9. A PPROACH 2: J ENSEN AGAIN
A further simpliﬁcation is obtained by applying Jensen inequality again to 128 but in the opposite direction, therefore we renounce to having a bound and look only for an approximation.
We have the new effective free energy:
[Equation]
This gives, for k (cid:54) =
k ∗ :
[Equation]
Notice that ∂ ω k ∗ ˜ φ k ∗ = − (cid:80) k
(cid:54) =
k ∗ ∂ ω k ˜ φ k ∗ .
In last formulas we used the deﬁnition of K in Eq.
We show in Fig.
4 the negligible difference between the two ArgMax versions when using BP on the layers before the last one (which performs only the ArgMax).
B E XPERIMENTAL DETAILS B. H YPER - PARAMETERS OF THE BP- BASED SCHEME
We include here a complete list of the hyper-parameters present in the BP-based algorithms.
Notice that, like in the SGD type of algorithms, many of them can be ﬁxed or it is possible to ﬁnd a prescription for their value that works in most cases.
However, we expect future research to ﬁnd even more effective values of the hyper-parameters, in the same way it has been done for SGD.
These hyper-parameters are: the mini-batch size bs ; the parameter ρ (that has to be tuned similarly to the learning rate in SGD); the damping parameter α (that performs a running smoothing on the BP ﬁelds along the dynamics by adding a fraction of the ﬁeld at the previous iteration, see Eqs.
; the initialization coefﬁcient (cid:15) that we use to to sample the parameters of our prior distribution q θ ( W ) according to θ (cid:96),t =
ki ∼ (cid:15) N (0 , 1) .
Different choices of (cid:15) correspond to different initial distribution of the weights’ magnetization m (cid:96)ki = tanh( θ (cid:96)ki ) , as is shown in Fig. 5); the number of internal steps of reinforcement τ max and the associated intensity of the internal reinforcement r .
The performances of the BP-based algorithms are robust in a reasonable range of these hyper-parameters.
A more principled choice of a good initialization condition could be made by adapting the technique from
Stamatescu et al.
Notice that among these parameters, the BP dynamics at each layer is mostly sensitive to ρ and α , so that in general we consider them layer-dependent.
See Sec.
B.9 for details on the effect of these parameters on the learning dynamics and on layer polarization (i.e. how the BP dynamics tends to bias the weights towards a single point-wise conﬁguration with high probability).
Unless otherwise stated we ﬁx some of the hyper-parameters, in particular: bs = 128 (results are consistent with other values of the batch-size, from bs = 1 up to bs = 1024 in our experiments), (cid:15)
= 1 . 0 , τ max
= 1 , r = 0 .
We use a damping parameter α ∈ (0 , 1) to stabilize the training, changing the updated rule for the weights’ means as follows [Equation] [Equation]
ϵ = 0.
ϵ
= 0.
ϵ
= 1.
ϵ
= 1.
m
P ( m )
B. A RCHITECTURES
In the experiments in which we vary the architecture (see Sec. 4.1), all simulations of the BP-based algorithms use a number of internal reinforcement iterations τ max = 1 .
Learning is performed on the totality of the training dataset, the batch-size is bs = 128 , the initialization coefﬁcient is (cid:15) = 1 . 0 .
For all architectures and all BP approximations, we use α = 0 .
8 for each layer, apart for the 501-501-501 MLP in which we use α = (0 . 1 , 0 . 1 , 0 . 1 , 0 . 9) .
Concerning the parameter ρ , we use ρ = 0 .
9 on the last layer for all architectures and BP approximations.
On the other layers we use: for the 101-101 and the 501-501 MLPs, ρ = 1 . 0001 for all BP approximations; for the 101101-101 MLP, ρ = 1 . 0 for BP and AMP while ρ = 1 . 001 for MF; for the 501-501-501 MLP ρ = 1 . 0001 for all BP approximations.
For the BinaryNet simulations, the learning rate is lr = 10 .for
all MLP architectures, giving the better performance among the learning rates we have tested, lr = 100 , 10 , 1 , 0 . 1 , 0 .
We notice that while we need some tuning of the hyper-parameters to reach the performances of
BinaryNet, it is possible to ﬁx them across datasets and architectures (e.g. ρ = 1 and α = 0 .
8 on each layer)
without in general losing more than 20% (relative) of the generalization performances, demonstrating that the BP-based algorithms are effective for learning also with minimal hyperparameter tuning.
The experiments on the Bayesian error are performed on a MLP with 2 hidden layers of 101 units on the MNIST dataset (binary classiﬁcation).
Learning is performed on the totality of the training dataset, the batch-size is bs = 128 , the initialization coefﬁcient is (cid:15)
= 1 . 0 .
In order to ﬁnd the pointwise conﬁgurations we use α = 0 .
8 on each layer and ρ = (1 . 0001 , 1 . 0001 , 0 . 9) , while to ﬁnd the Bayesian ones we use α = 0 .
8 on each layer and ρ = (0 . 9999 , 0 . 9999 , 0 . 9) (these value prevent an excessive polarization of the network towards a particular pointwise conﬁgurations).
For the continual learning task (see Sec. 4.5) we ﬁxed ρ = 1 and α = 0 .
8 on each layer as we empirically observed that polarizing the last layer helps mitigating the forgetting while leaving the single-task performances almost unchanged.
B. V ARYING THE DATASET
When varying the dataset (see Sec. 4.3), all simulation of the BP-based algorithms use a number of internal reinforcement iterations τ max = 1 .
Learning is performed on the totality of the training dataset, the batch-size is bs = 128 , the initialization coefﬁcient is (cid:15) = 1 . 0 .
For all datasets (MNIST (2 classes), FashionMNIST (2 classes), CIFAR-10 (2 classes), MNIST, FashionMNIST, CIFAR-10) and all algorithms (BP, AMP, MF) we use ρ = (1 . 0001 , 1 . 0001 , 0 . 9) and α = 0 .
8 for each layer.
Using in the ﬁrst layers values of ρ = 1 + (cid:15) with (cid:15) ≥ 0 and sufﬁciently small typically leads to good results.
For the BinaryNet simulations, the learning rate is lr = 10 .
(both for binary classiﬁcation and multi-class classiﬁcation), giving the better performance among the learning rates we have tested, lr = 100 , 10 , 1 , 0 . 1 , 0 . 001 .
In Tab. 2 we report the ﬁnal train errors obtained on the different datasets.
[Table]
B. L OCAL ENERGY
We adapt the notion of ﬂatness used in (Jiang et al., 2020; Pittorino et al., 2021), that we call local energy, to conﬁgurations with binary weights.
Given a weight conﬁguration w ∈ {± 1 } N , we deﬁne the local energy δE train ( w , p ) as the average difference in training error E train ( w ) when perturbing w by ﬂipping a random fraction p of its elements:
[Equation]
where (cid:12) denotes the Hadamard (element-wise) product and the expectation is over i.i.d.
entries for z equal to − 1 with probability p and to +1 with probability 1 − p .
We report the resulting local energy proﬁles (in a range [0 , p max ] ) in Fig.
6 right panel for BP and BinaryNet.
The relative error grows slowly when perturbing the trained conﬁgurations (notice the convexity of the curves).
This shows that both BP-based and SGD-based algorithms ﬁnd conﬁgurations that lie in relatively ﬂat minima in the energy landscape.
The same qualitative phenomenon holds for different architectures and datasets.
B. SGD IMPLEMENTATION (B INARY N ET )
We compare the BP-based algorithms with SGD training for neural networks with binary weights and activations as introduced in BinaryNet (Hubara et al., 2016).
This procedure consists in keeping a continuous version of the parameters w which is updated with the SGD rule, with the gradient calculated on the binarized conﬁguration w b = sign( w ) .
At inference time the forward pass is calculated with the parameters w b .
The backward pass with binary activations is performed with the so called straight-through estimator .
Our implementation presents some differences with respect to the original proposal of the algorithm in (Hubara et al., 2016), in order to keep the comparison as fair as possible with the BP-based algorithms, in particular for what concerns the number of parameters.
We do not use biases nor batch normalization layers, therefore in order to keep the pre-activations of each hidden layer normalized we rescale them by 1 √ N where N is the size of the previous layer (or the input size in the case of the pre-activations afferent to the ﬁrst hidden layer).
The standard SGD update rule is applied (instead of Adam), and we use the binary cross-entropy loss.
Clipping of the continuous conﬁguration w in [ − 1 , 1] is applied.
We use Xavier initialization (Glorot & Bengio, 2010) for the continuous weights.
In Fig.2 of the main paper, we apply the Adam optimization rule, noticing that it performs slightly better in train and test generalization performance compared to the pure SGD one.
[Figure]
l
[Figure] BinaryNet [Figure] B. EBP IMPLEMENTATION
Expectation Back Propagation (EBP) Soudry et al.
(2014b) is parameter-free Bayesian algorithm that uses a mean-ﬁeld (MF) approximation (fully factorized form for the posterior) in an online environment to estimate the Bayesian posterior distribution after the arrival of a new data point.
The main differences between EBP and our approach relies in the approximation for the posterior distribution.
Moreover we explicitly base the estimation of the marginals on the local high entropy structure.
The fact that EBP works has no clear explanation: certainly it cannot be that the MF assumption holds for multi-layer neural networks.
Still, it’s certainly very interesting that it works.
We argue that it might work precisely by virtue of the existence of high local entropy minima and expect it to give similar performance to the MF case of our algorithm.
The online iteration could in fact be seen as way of implementing a reinforcement.
We implemented the EBP code along the lines of the original matlab implementation (https://github.com/ExpectationBackpropagation/EBP_Matlab_Code).
In order to perform a fair comparison we removed the biases both in the binary and continuous weights versions.
It is worth noticing that we faced numerical issues in training with a moderate to big batchsize All the experiments were consequently limited to a batchsize of 10 patterns
B. U NCERTAINTY UNDER D ATASET SHIFT
As a further validation of our method, we computed the predictive uncertainty under dataset shift of our Bayesian prediction and compare them with the Bayesian prediction obtained with EBP.
We performed a prototypical experiment where for a given model ( 2 hidden layers with 101 units each) we rotated each image from the train set by a given angle θ and measured standard uncertainty scores (ECE and Brier scores, see e.g. Ovadia et al.
for a review)
as function of the angle θ , for both methods.
B. U NIT POLARIZATION AND OVERLAPS
We deﬁne the self-overlap or polarization of a given unit a as q a 0 = 1 N (cid:80) i ( w ai ) 2 , where N is the number of parameters of the unit and { w ai } Ni =1 its weights.
It quantiﬁes how much the unit is polarized towards a unique point-wise binary conﬁguration ( q a 0 = 1 corresponding to high conﬁdence in a given conﬁgurations while q a 0 = 0 to low).
The overlap between two units a and b (considered in the same layer) is q ab = 1 N (cid:80) w a i w b i .
The number of parameters N is the same for units belonging to the [Figure] same fully connected layer.
We denote by (cid:104) q 0 (cid:105) =
1 N out (cid:80) N out a =1 q a 0 and (cid:104) q ab (cid:105)
=
1 N out (cid:80) N out a<b q ab the mean polarization and mean overlap in a given layer (where N out is the number of units in the layer).
The parameters ρ and α govern the dynamical evolution of the polarization of each layer during training.
A value ρ (cid:39) 1 has the effect to progressively increase the units polarization during training, while ρ < 1 disfavours it.
The damping α which takes values in [0 , 1] has the effect to slow the dynamics by a smoothing process (the intensity of which depends on the value of α ), generically favoring convergence.
Given the nature of the updates in Algorithm 1, each layer presents its own dynamics given the values of ρ (cid:96) and α(cid:96) at layer (cid:96) , that in general can differ from each other.
We ﬁnd that it is is beneﬁcial to control the polarization layer-per-layer, see Fig.
7 for the corresponding typical behavior of the mean polarization and the mean overlaps during training.
Empirically, we have found that (as we could expect) when training is successful the layers polarize progressively towards q 0 = 1 , i.e. towards a precise point-wise solution, while the overlaps between units in each hidden layer are such that q ab (cid:28) 1 (indicating low symmetry between intra-layer units, as expected for a non-redundant solution).
To this aim, in most cases α(cid:96) can be the same for each layer, while tuning ρ (cid:96) for each layer allows to ﬁnd better generalization performances in some cases (but is not strictly necessary for learning).
In particular, it is possible to use the same value ρ (cid:96) for each layer before the last one ( (cid:96) <
L where L is the number of layers in the network), while we have found that the last layer tends to polarize immediately during the dynamics (probably due to its proximity to the output constraints).
Empirically, it is usually beneﬁcial for learning that this layer does not or only slightly polarize, i.e.
(cid:104) q 0 (cid:105) (cid:28) 1 (this can be achieved by imposing ρ L < 1 ).
Learning is anyway possible even when the last layer polarizes towards (cid:104) q 0 (cid:105)
= 1 along the dynamics, i.e. by choosing ρ L sufﬁciently large.
As a simple general prescription in most experiments we can ﬁx α = 0 .
8 and ρ L = 0 .
9 , therefore leaving ρ (cid:96)<L as the only hyper-parameter to be tuned, akin to the learning rate in SGD.
Its value has to be very close to 1 .
(a value smaller than 1 . 0 tends to depolarize the layers, without focusing on a particular point-wise binary conﬁguration, while a value greater than 1 .
tends to lead to numerical instabilities and parameters’ divergence).
B. C OMPUTATIONAL PERFORMANCE : VARYING BATCH - SIZE
In order to compare the time performances of the BP-based algorithms with our implementation of BinaryNet, we report in Fig.
8 the time in seconds taken by a single epoch of each algorithm in function of the batch-size, on a MLP of 2 layers of 501 units on Fashion-MNIST.
We test both
RTX and classiﬁcation present a very similar time scaling with the batch-size, in both cases comparable with BinaryNet.
Let us also notice that BP-based algorithms are able to reach generalization performances comparable to
BinaryNet for all the values of the batch-size reported in this section.
[Figure]
BP
BPI
AMP MF
BinaryNet