# Towards Explainable Artificial Intelligence for GNSS Multipath LSTM Training Models
## 3 Methodology: LRP for LSTM-Based GNSS Multipath Detection
### Implementation of LRP for LSTM-Based RNNs  
After understanding the theoretical framework of both LSTM-based RNNs and Layer-wise Relevance Propagation, we now present a systematic approach to implementing LRP specifically for LSTM architectures. The implementation must address the unique characteristics of LSTM-based RNNs while maintaining the core principles of relevance conservation. For this purpose, we first introduce some notation. Let \(s,g\) be the neurons representing the signal and the gate, let \(p\) be the neuron representing the product of these two quantities. Let \(f\) be the neuron corresponding to the forget gate. Let \(k\) be the neuron on which the signal is being accumulated. Let \(k-1,p-1,\ldots\) be the same neurons at previous time steps. Let \(a\) be the output of the activation. LSTM forward pass can be decomposed into the following three elementary types of computation:  
1. linear mappings \(z_{s}=\sum\limits_{j}a_{j}w_{js},\ z_{g}=\sum\limits_{j}a_{j}w_{js}\)
2. gated interactions \(a_{p}=\tanh(z_{s})\cdot\sigma(z_{g})\)
3. accumulation \(a_{k}=a_{f}\cdot a_{k-1}+a_{p}\)  
The implementation of LRP begins with recording all necessary activations during the forward pass. Algorithm 1 is the pseudocode for forward pass recording.  
```
Input: LSTM model M, input sequence X Output: Activation records A Initialize activation storage A  For each time step \(t\): Record input gate activations: \(i_{t}=\sigma(W_{t}x_{t}+U_{t}h_{t-1}+b_{t})\) Record forget gate activations: \(f_{t}=\sigma(W_{f}x_{t}+U_{f}h_{t-1}+b_{f})\) Record cell state: \(c_{t}=f_{t}\odot c_{t-1}+i_{t}\odot\tanh(W_{c}x_{t}+U_{c}h_{t-1}+b_{c})\) Record output gate activations: \(o_{t}=\sigma(W_{o}x_{t}+U_{o}h_{t-1}+b_{o})\) Record hidden state: \(h_{t}=o_{t}\odot\tanh(c_{t})\) Store all activations in A Return A
```  
**Algorithm 1**Forward Pass Recording  
The relevance is initialized at the output layer and propagated backward, as illustrated in Algorithm 2:  
```
Input: Final prediction \(P\), target class \(c\) Output: Initial relevance \(R_{0}\) If classification task: Set \(R_{0}[c]=1\) (for target class) Set \(R_{0}[i]=0\) (for all other classes) Else if regression task: Set \(R_{0}=P\) Return \(R_{0}\)
```  
**Algorithm 2**Relevance Initialization  
Algorithm 3 is the core of the implementation which handles the propagation through LSTM cells. Unlike linear mappings with their straightforward summation structure, LSTM cells contain multiplicative interactions that make relevance propagation more challenging. To address this complexity, [PERSON] et al. (2015) introduced the signal-take-all redistribution rule,  
\[(R_{g},R_{s})=(0,R_{p})\]  
This kind of redistribution provides a systematic way to handle relevance attribution through these nonlinear gated interactions.  
The \"signal-take-all\" approach addresses the key challenge of determining how relevance should flow through an LSTM cell's gates, where the output is controlled by multiplicative interactions rather than simple weighted sums. This method acknowledges that while gates control the flow of information, the actual information content resides in the signal path.  
This implementation framework provides a structured approach to applying LRP to LSTM-based RNNs while maintaining computational efficiency and numerical stability. The modular design allows for easy adaptation to different LSTM architectures and application requirements.  
Having established our methodological framework, we now evaluate its effectiveness through a series of experiments designed to test both prediction accuracy and interpretability.