# DLSTM-Based Successive Cancellation Flipping Decoder for Short Polar Codes
## 3 The Proposed SC Flipping Algorithm
### DLSTM-Based SC Flipping Algorithm  
We utilized the well-trained DLSTM network to determine the flipping set of the first error bit. According to Author23 [23], the channels reliability ordering can be used to determine the flipping positions in SC flipping decoder. Therefore, we adopted channel reliability to determine the multiple error bits. This method avoids the ordering of the LLRs, which reduces the complexity of SC flipping decoder. Figure 8 illustrates the process of the DLSTM-based SC flipping algorithm, which consists of the following steps.  
(1) Perform the SC decoding and check whether the decoding result can pass the CRC detector. If pass, the decoding is successful. Otherwise, go to Step 2.  
(2) Take advantage of the well-trained DLSTM to predict the probability of error occurring in the information bits. Then, sort their probabilities in descending order. Select the index of the \(T_{1}\) maximum probability and map them to the corresponding locations of the information bits. \(T_{1}\) is the maximum number of one-bit flipping and is also the size of the flipping set. Employ these locations to construct the flipping set \(\mathcal{W}_{1}^{T}=(w_{1},w_{2},\ldots,w_{T_{1}})\), where \(w_{1},w_{2},\ldots,w_{T_{1}}\) are the candidate bits for the first error bit and the probability \(w_{1}>w_{2}>\cdots>w_{T_{1}}\), and go to Step 3.  
(3) Select \(w_{1}\) for flipping. If the decoding fails, flip the following bits \(w_{2},w_{3},\ldots,w_{T_{1}}\) successively. If \(T_{1}\) attempts are unsuccessful, then go to Step 4. Otherwise, terminate the decoding.  
(4) Calculate the channel reliability of flipping set \(\mathcal{W}_{1}^{T}\) by Gaussian approximation. For \(\mathcal{W}_{1}^{T}=(w_{1},w_{2},\ldots,w_{T_{1}})\), reorder into \(\mathcal{W}_{2}^{T}=(w_{1}^{\prime},w_{2}^{\prime},\ldots,w_{T_{1}}^{\prime})\) in ascending order  
Figure 8: The SC Flipping algorithm based on DLSTM.  
according to reliability, where the reliability follows: \(w^{\prime}_{1}<w^{\prime}_{2}<\dots<w^{\prime}_{T_{1}}\). Select \(w^{\prime}_{1}\) and \(w^{\prime}_{2}\) from \(\mathcal{W}^{T}_{2}\) to perform bit flipping at the same time. If the CRC detector fails, next select \((w^{\prime}_{1},w^{\prime}_{3})\), \((w^{\prime}_{1},w^{\prime}_{4})\),..., \((w^{\prime}_{T_{1}-1},w^{\prime}_{T_{1}})\) in turn to flip. If \(T_{2}\) attempts are unsuccessful, the decoding fails, where \(T_{2}\) is the maximum number of two-bit flipping. Otherwise, the decoding is successful. The selection method is shown in Figure 9.  
The pseudocode for two-bit flipping algorithm based on the DLSTM network is shown in Algorithm 2. It can be extended to multi-bit flipping in a similar way. The maximum number of candidate bits is \(K\). The set of multi-bit flipping is denoted as \(\mathcal{W}^{T}_{3}\), \(\mathcal{W}^{T}_{4}\),..., \(\mathcal{W}^{T}_{K}\). When simultaneously flipping the least reliable 3, 4,..., \(K\) bits, the maximum number of flips is indicated as \(T_{3}\), \(T_{4}\),..., \(T_{K}\).  
```
0:\(y^{N}_{1}\), \(\mathcal{W}^{T}_{1}\), \(\mathcal{W}^{T}_{2}\), \(T_{1}\), \(T_{2}\)
0:\(\hat{u}^{N}_{1}\)
1:\(\{\hat{u}^{N}_{1},\text{LLR}\}\leftarrow\) SC (\(y^{N}_{1}\))
2:\(t_{1}=0\), \(t_{2}=0\)
3:while\(\hat{u}^{N}_{1}\) fail CRC and \(t_{1}<T_{1}\)do
4:\(\mathcal{W}^{T}_{1}\leftarrow\) DLSTM
5:\(\hat{u}^{N}_{1}\leftarrow\) SC flip (\(y^{N}_{1},\mathcal{W}^{T}_{1}(t_{1})\))
6:if\(\hat{u}^{N}_{1}\) pass CRC then
7: break
8:else
9:\(t_{1}\gets t_{1}+1\)
10:endif
11:endwhile
12:if\(t_{1}\geq T_{1}\)then
13:\(t_{1}=0\)
14:while\(\hat{u}^{N}_{1}\) fail CRC do
15:for\(i\gets t_{1}+1\) to \(T_{1}\)do
16:if\(t_{2}<T_{2}\)then
17:\(\hat{u}^{N}_{1}\leftarrow\) SC flip (\(y^{N}_{1},\mathcal{W}^{T}_{2}(t_{1},i)\))
18:if\(\hat{u}^{N}_{1}\) pass CRC then
19: break
20:else
21:\(t_{2}\gets t_{2}+1\)
22:endif
23:endif
24:endif
25:endfor
26:\(t_{1}\gets t_{1}+1\)
27:endwhile
28:endif
29:return\(\hat{u}^{N}_{1}\)
```  
**Algorithm 2** Two-bit flipping algorithm based on the DLSTM.