# Spectral Information Divergence-Driven Diffusion Networks for Hyperspectral Target Detection
## 3 Proposed Method
### Background Learning Based on Diffusion Model
\[\mathbf{\hat{t}} =\text{Emb}_{t}(\mathbf{t};\gamma_{\text{te}}),\] (14) s.t., \[\gamma_{\text{te}}\in\gamma\]  
where \(\text{Emb}_{t}(;\gamma_{te})\) denotes the temporal embedding function network and \(\gamma_{te}\) represents its parameters. \[\widetilde{\mathbf{B}}^{t}=g\big{(}\mathbf{B}^{t},\gamma_{\text{linear}} \big{)}+\mathbf{\hat{t}} \tag{15}\]  
where \(g(;\gamma_{linear})\) is the linear transformation layer, with \(\gamma_{linear}\) as its parameter. This paper employs a differential transformer-based network for the denoising model [55]. Transformer models often allocate excessive attention to task-irrelevant contextual information, leading to an overemphasis on non-critical parts. The differential attention mechanism mitigates this issue by removing attentional noise and directing the model's focus toward crucial information. This approach is conceptually analogous to differential amplifiers in electrical engineering. For a given input background sample \(\widetilde{\mathbf{B}}\in\mathbb{R}^{(h\times w)\times L}\), it is first projected onto queries, keys, and values: \(\mathbf{Q}_{1},\mathbf{Q}_{2},\mathbf{K}_{1},\mathbf{K}_{2}\in\mathbb{R}^{(h \times w)\times L}\) and \(\mathbf{V}\in\mathbb{R}^{(2\times h\times w)\times L}\). The differential attention \(Diff(\cdot)\) is then calculated as follows:  
\[ \begin{split}[\mathbf{Q}_{1};\mathbf{Q}_{2}]&= \widetilde{\mathbf{B}}\mathbf{W}^{Q},[\mathbf{K}_{1};\mathbf{K}_{2}]= \widetilde{\mathbf{B}}\mathbf{W}^{K},V=\widetilde{\mathbf{B}}\mathbf{W}^{V}\\ Diff(\widetilde{\mathbf{B}})&=(\text{softmax}( \frac{\mathbf{Q}_{1}\mathbf{K}_{1}^{T}}{\sqrt{d}})-\lambda\,\text{softmax}( \frac{\mathbf{Q}_{2}\mathbf{K}_{2}^{T}}{\sqrt{d}}))\mathbf{V}\end{split}  \tag{16}\]  
where \(\mathbf{W}^{Q},\mathbf{W}^{K},\mathbf{W}^{V}\in\mathbb{R}^{(2\times h\times w )\times L}\), and \(\lambda\) is learnable shared parameter, designed as  
\[\lambda=\text{exp}\big{(}\lambda_{\mathbf{q}_{1}}\cdot\lambda_{\mathbf{k}_{1} }\big{)}-\text{exp}\big{(}\lambda_{\mathbf{q}_{2}}\cdot\lambda_{\mathbf{k}_{2 }}\big{)}+\lambda_{\text{init}} \tag{17}\]where \(\lambda_{\mathbf{q}_{1}},\lambda_{\mathbf{k}_{1}},\lambda_{\mathbf{q}_{2}},\lambda_{ \mathbf{k}_{2}}\) are learnable parameters, while \(\lambda_{\mathrm{init}}\) serves as a hyperparameter. Additionally, the multi-head attention mechanism employs, \(\mathbf{W}_{i}^{Q},\mathbf{W}_{i}^{K},\mathbf{W}_{i}^{V}\), where \(i\in[1,h]\). \(\mathbf{W}^{O}\) is a learnable projection matrix. \[ \begin{split}\mathbf{head}_{i}=\mathbf{D}\left(\widetilde{ \mathbf{B}};\mathbf{W}_{i}^{Q},\mathbf{W}_{i}^{K},\mathbf{W}_{i}^{V},\lambda \right)\\ \overline{\mathbf{head}_{i}}=(1-\lambda_{\mathrm{init}})\cdot \left(\overline{\mathbf{head}_{i}}\right)\\ \mathbf{MultiHead}(\widetilde{\mathbf{B}})=\ \mathrm{Concat}\left( \overline{\mathbf{head}_{i}}\cdots,\overline{\mathbf{head}_{h}}\right) \mathbf{W}^{O}\end{split}  \tag{18}\]  
The output \(\widetilde{n}\) is obtained after a linear layer transformation. The mean squared error loss function \(\mathcal{L}_{1}\) used for the diffusion model is  
\[\mathcal{L}_{1}=\min_{\theta,t}\left(\left\|\mathbf{N}-f\left(\mathbf{B}^{t}; \gamma\right)\right\|_{2}\right) \tag{19}\]  
The background samples classified during coarse detection are often misclassified. To improve the reliability of background reconstruction, this paper proposes a SID-based loss function, which serves as a criterion for target suppression during training. It is introduced in Section 2. The SID is calculated as shown in Equation (2), and the average SID value for each sample is represented as \(\mathcal{L}_{sid}\),as given in Equation (20):  
\[\mathcal{L}_{sid}=\frac{1}{m}\sum_{i}^{m}SID[i] \tag{20}\]  
where \(m\) is the number of background samples. Consequently, the total loss function is expressed in Equation (21):  
\[\mathcal{L}_{total}=\mathcal{L}_{1}-\delta\times\mathcal{L}_{sid} \tag{21}\]