# Deep-Learning Based Algorithm for Detecting Targets in Infrared Images
## 4 CMF-3 DLSTM
### Model Training Strategy  
CMF-3 DLSTM uses the same training methods of pre-training migration and model fine-tuning as CMF Net, but the training strategy of the classification module is different. In the classification module, 3 DLSTM is based on three bidirectional long- and short-term memory networks, while the network structure of Bi-LSTM is based on LSTM. Therefore, the ultimate goal of 3 DLSTM is the same as that of LSTM, which is to minimize a loss function \(L(t)\). The specific calculation formula is as follows:  
\[L=\sum_{t=1}^{T}l(t) \tag{6}\]where \(t\) represents the current moment, \(T\) represents the total time step, and \(l(t)\) represents the loss function at the current moment. The calculation formula of \(l(t)\) is as follows:  
\[l(t)=f(h(t),y(t))=\left\|h(t)-y(t)\right\|^{2} \tag{7}\]  
\(h(t)\) represents the hidden layer output at the current time \(t\), and \(y(t)\) represents the output layer output at the present time \(t\). To minimize \(l(t)\) loss function, the 3 DLSTM network is trained by the gradient descent method. When the error is propagated back, the chain derivative method is used to update the model weight parameters. The specific calculation formula is as follows:  
\[\frac{\partial L}{\partial w}=\sum_{l=1}^{T}\sum_{i=1}^{M}\frac{\partial L}{ \partial h_{i}(t)}\cdot\frac{\partial h_{i}(t)}{\partial w} \tag{8}\]  
\(i\) represents the memory unit of the hidden layer. \(M\) is the number of memory units. \(w\) represents the model weight parameter. \(h_{i}(t)\) represents the output of the memory unit in the hidden layer at the current time \(t\). After calculating the gradient of weight parameter \(w\) of all models, 3 DLSTM uses the gradient descent method to update the parameters iteratively. Finally, it minimizes the loss function \(L\) to achieve the purpose of training the classification module. For infrared image target detection model CMF-3 DLSTM, a joint optimization 10-step training process is designed in this paper, as shown in Algorithm 1. ```
Input: Infrared image dataset. Output: Target detection model CMF-3 DLSTM. Step 1: Initialize the network parameters in Step2 and Step3 using the pre-training model on the VOC2007 dataset. Step 2: Use the first multiscale feature extraction mechanism to extract feature information. Step 3: Using the second multiscale feature extraction mechanism to extract feature information. Step 4: CMF Net is used to carry out feature fusion for the feature information extracted by Step 2 and Step 3. Step 5: Train the RPN network to generate the proposals using the characteristic information obtained from Step 4. Step 6: Implement ROI Pooling of Step 5 and adjust them to the same size. Step 7: The 3 DLSTM network is used to extract the context information of ROI in Step 6. Step 8: The attention mechanism is used to assign weight to the output of the features by Step 7. Step 9: Classification layer and regression layer are used for target detection for the output of the features by Step 8. Step10: The unified network of Step 5 and Step 9 joint training is taken as the final model. ```  
**Algorithm 1** CMF-3 DLSTM training process  
The training parameters of CMF-3 DLSTM, CMF Net, and Faster R-CNN are shown in Table 2, in which Faster R-CNN has 136,708,989 training parameters, and CMF Net has 152,048,765 training parameters. The number of training parameters of CMF-3 DLSTMA is 40,761,469, which drops to the level of 10 million and dramatically reduces the space complexity of the algorithm. However, the 3 DLSTM network and attention mechanism introduced in the classification module of CMF-3 DLSTM is more complex than the fully connected layer in the classification module of CMF Net, thus causing an increase in time complexity. The CMF Net model performs target detection at a speed of about 0.87 s/pc on a machine with a graphics card configuration of GeForce GTX 1080.