# Antimicrobial Peptide Screening from Microbial Genomes in Sludge Based on Deep Learning
## 2 Materials and Methods
### Alstm  
The attention-based LSTM (ALSTM) model is an extension of the traditional LSTM model, incorporating both LSTM and an attention mechanism. The LSTM model consists of an input layer, a hidden layer, and an output layer. The input layer receives the dataset as input, and the hidden layer contains multiple LSTM units responsible for processing sequence data and extracting key features. The output layer is a fully connected layer that outputs the probability of antimicrobial activity for peptide segments. The LSTM model comprises numerous LSTM units, each encompassing distinct components, including a forget gate, an input gate, and an output gate. In this architecture, the forget gate manages the retention or omission of information from the preceding time step in the memory cell. Simultaneously, the input gate regulates the acceptance or rejection of input at the current time step by the memory cell. Finally, the output gate determines whether the output at the current time step proceeds to the subsequent LSTM unit or the output layer. The calculation is as follows:  
\[c_{t}=\tanh(w_{c}(h_{t-1}+x_{t})+b_{c}) \tag{1}\]  
\[a_{t}=\tanh(w_{a}(h_{t-1}+x_{t})+b_{a}) \tag{2}\]  
\[f_{t}=\sigma(w_{f}(h_{t-1}+x_{t})+b_{f}) \tag{3}\]  
\[i_{t}=a_{t}+c_{t} \tag{4}\]  
\[c_{t}=f_{t}\circ c_{t-1}+i_{t}\circ c_{t} \tag{5}\]  
\[o_{t}=\sigma(w_{o}(h_{t-1}+x_{t})+b_{o}) \tag{6}\]  
\[h_{t}=o_{t}\circ\tanh(c_{t}) \tag{7}\]  
In the equation, \(c_{t}\) represents the cell state at the current time step \(t\), which is a key internal variable used to carry information through the network. \(h_{t-1}\) is the hidden state from the previous time step \(t\)-1, and \(x_{t}\) is the input at the current time step. The weight matrices \(w(w_{a},w_{c},w_{f},w_{o})\) and bias vectors \(b(b_{a},b_{c},b_{f},b_{o})\) are parameters learned by the network. The hyperbolic tangent activation function tanh is used to generate the candidate state \(c_{t}\) and the activation value \(a_{t}\), while the sigmoid activation function \(\sigma\) is used to control the forget gate \(f_{t}\) and the output gate \(o_{t}\). \(i_{t}\) represents the value of the input gate, determining how much new information will be incorporated into the cell state. \(c_{t-1}\) is the cell state from the previous time step. \(h_{t}\) is the hidden state at the current time step, calculated as the Hadamard product (element-wise multiplication) of the current output gate value \(o_{t}\) and the current cell state \(c_{t}\) processed through tanh. ALSTM relying on an attention mechanism enables the model to focus on the most relevant parts of the input sequence for making predictions. Its input layer is similar to the LSTM model and receives sequential data. In the attention-based hidden layer, the attention mechanism is applied to process the input data. The so-called attention weights \begin{table}
\begin{tabular}{c c c} \hline \hline
**Dataset** & **Positive** & **Negative** \\ \hline Training set & 4370 & 5132 \\ Test set & 2211 & 2543 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: The dataset used for model construction. determine the model's focus on different parts of the input sequence, and their calculation is as follows:  
\[a_{t}=\frac{\exp(score(h_{t-1},x_{t}))}{\sum\limits_{j=1}^{T_{x}}\exp(score(h_{t- 1},x_{j}))} \tag{8}\]  
In attention mechanisms, a scoring function is commonly used to calculate the relevance score of each component in the input sequence (such as each hidden state in an LSTM network) to the current output. This score reflects the contribution size of each input element in generating the current output, enabling the model to dynamically focus attention on the most crucial parts of the input sequence. This mechanism, when applied to genomic sequences, allows the model to consider the critical features of the input sequence during prediction, enhancing the accuracy and efficiency of predictions.