# Adaptive Learned Belief Propagation for Decoding Error-Correcting Codes
## 4 Weighted Belief Propagation  
Given a code \(\mathcal{C}\), one can construct a bipartite Tanner graph \(T_{\mathcal{C}}=(C,V,E)\), where \(C=[m]\), \([m]\triangleq 1,2,\ldots,m\), \(V=[n]\), and \(E=\{(c,v)\in C\times V\mid\operatorname{H}_{c,v}\
eq 0\}\) are, respectively, the set of check nodes, variable nodes and the edges connecting them. Let \(V_{c}=\{v\in V\mid(c,v)\in E\}\), \(C_{v}=\{c\in C\mid(c,v)\in E\}\), and \(d_{c}\) and \(d_{v}\) be the degree of \(c\) and \(v\) in \(T_{\mathcal{C}}\), respectively.  
The WBP is an iterative decoder based on the exchange of the weighted LLRs between the variable nodes and the check nodes in \(T_{\mathcal{C}}\)[11, 79]. Let \(\operatorname{L}_{c2v}^{(t)}\) denote the extrinsic LLR from the check node \(c\) to the variable node \(v\) at iteration \(t\). Define similarly \(\operatorname{L}_{v2c}^{(t)}\).  
The decoder is initialized at \(t=1\) with \(\operatorname{L}_{v2c}^{(0)}=\operatorname{L}(y_{j})\), where \(v\) is the \(j\)-th variable node, and \(\operatorname{L}(y_{j})\) is obtained from (3) or (7). For iteration \(t\in[T]\), the LLRs are updated in two steps.  
The check node update:  
\[\operatorname{L}_{c2v}^{(t)} \overset{(a)}{=}2\tanh^{-1}\Bigl{\{}\prod_{v^{\prime}\in V_{c} \setminus\{v\}}\tanh\frac{\gamma_{v^{\prime},c}^{(t)}}{2}\operatorname{L}_{v^ {\prime}2c}^{(t-1)}\Bigr{\}}\] \[\overset{(b)}{\approx}\operatorname{L}_{c,v}\prod_{v^{\prime} \in V_{c}\setminus\{v\}}\gamma_{v^{\prime},c}^{(t)}\operatorname{sign}\Bigl{(} \operatorname{L}_{v^{\prime}2c}^{(t-1)}\Bigr{)}, \tag{9}\]  
where  
\[\operatorname{L}_{c,v}=\min_{v^{\prime}\in V_{c}\setminus\{v\}}\Bigl{\{} \Bigl{|}\operatorname{L}_{v^{\prime}2c}^{(t-1)}\Bigr{|}\Bigr{\}}.\]  
The equation in \((a)\) represents the update relation in the BP [69], where the LLR messages are scaled by non-negative weights \(\{\gamma_{v,c}^{(t)}:v\in V,c\in C_{v},t\in[T]\}\). Further, \((b)\) is obtained from \((a)\) though an approximation to lower the computational cost. The WBP and WMS decoders use \((a)\) and \((b)\), respectively.  
The variable-node update:  
\[\operatorname{L}_{v2c}^{(t)}=\alpha_{v}^{(t)}\operatorname{L}(\mathbf{y})+ \sum_{c^{\prime}\in C_{v}\setminus\{c\}}\beta_{c^{\prime},v}^{(t)} \operatorname{L}_{c^{\prime}2v}^{(t-1)}. \tag{10}\]  
This is the update relation in the BP, to which the sets of non-negative weights \(\{\alpha_{v}^{(t)}:v\in V,t\in[T]\}\) and \(\{\beta_{c,v}^{(t)}:c\in C,v\in V_{c},t\in[T]\}\) are introduced.  
At the end of each iteration \(t\), a hard decision is made  
\[\vec{y}_{j}=\begin{cases}1,&\text{if }\operatorname{L}_{v}^{(t)}<0,\\ 0,&\text{if }\operatorname{L}_{v}^{(t)}\geq 0,\end{cases} \tag{11}\]where  
\[\mathrm{L}_{v}^{(t)}=\mathrm{L}(y_{j})+\sum_{c\in\mathbb{C}_{v}}\mathrm{L}_{c2v}^{( t)}. \tag{12}\]  
Let \(\bar{\mathbf{y}}=(g_{1},g_{2},\cdots,g_{n})\in\mathbb{F}_{2}^{n}\), and let \(\mathbf{s}=\bar{\mathbf{y}}\mathrm{H}^{T}\in\mathbb{F}_{2}^{m}\) be the syndrome. The algorithm stops if \(\mathbf{s}=\mathbf{0}\) or \(t=T\).  
The computation in (9) and (10) can be expressed with an NN. The Tanner graph \(T_{C}\) is unrolled over the iterations to obtain a recurrent network with 2T layers (see Figure 2), in which the weights \(\gamma_{v,c}^{(t)}\) and \(\beta_{c,v}^{(t)}\) are assigned to the edges of \(T_{C}\), and the weights \(\alpha_{v}^{(t)}\) to the outputs [16]. The weights are obtained by minimizing a loss function evaluated over a training dataset using the standard optimizers for NNs.