# Design of a Lung Lesion Target Detection Algorithm Based on a Domain-Adaptive Neural Network Model
## 3 Methodology
### Transfer Learning and Domain Adaptation  
Transfer learning leverages the inherent similarities between datasets, tasks, or models to transfer knowledge and methodologies acquired in a large data-rich domain to a data-scar domain. This approach facilitates the resolution of new problems more efficiently and effectively, often accelerating learning processes and improving overall performance. For transfer learning, it is assumed that there is a source domain \(D_{s}=\{X_{s},Y_{s}\}\) and a target domain \(D_{t}=\{X_{t},Y_{t}\}\), and the goal of transfer learning is to utilize the source domain knowledge \(P_{s}(X,Y)\) to improve the model performance on the target domain \(P_{t}(X,Y)\). The target domain model is initialized with pre-trained model parameters \(\theta_{s}\) and the parameters are updated with target domain data:  
\[\theta_{t}=\underset{\theta}{\text{argmin}}\mathcal{L}_{t}(f_{\theta}(X_{t}), Y_{t}) \tag{3}\]where \(\mathcal{L}_{t}\) is the loss in target domain and \(f_{\theta}\) is the model. Domain adaptation is a focused branch of transfer learning that tackles the problem of different feature distributions between the source and target domains. By adjusting the model's feature representations, it enables smooth knowledge transfer between these domains [31]. A key part of domain adaptation is reducing the gap between their feature distributions. In this study, we use Maximum Mean Discrepancy (MMD), which is calculated as follows:  
\[\text{MMD}(X_{s},X_{t})=\frac{1}{n_{s}}\sum_{i=1}^{n_{t}}\phi(x_{i}^{s})-\frac{ 1}{n_{t}}\sum_{j=1}^{n_{t}}\phi\Big{(}x_{j}^{t}\Big{)}^{2} \tag{4}\]  
where \(\phi\) is the feature mapping function, and \(n_{s}\), \(n_{t}\) represents sample numbers in the source and target domains. After calculating the coarse-grained similarity between high-resolution and low-resolution images using the MMD metric, images with high similarity can be matched based on their similarity scores and then passed into a translation network. This module generates high-resolution images by harnessing the powerful capabilities of the image-to-image translation network. Drawing inspiration from the remarkable success of CycleGAN in image translation tasks, the domain transformation module adopts a network structure similar to CycleGAN. It consists of two key components: a coarse-grained similarity computation module and an image translation network for domain transformation. The coarse-grained similarity computation serves to identify input images with high similarity, which facilitates network convergence and enhances the performance of the translation network. The overall workflow is depicted in Figure 1.  
The adversarial loss function ensures that the generator produces samples that align with the target domain's distribution. However, relying only on adversarial loss cannot fully guarantee a one-to-one correspondence between the input image and the desired output image. To overcome this limitation and provide additional regularization for the translation network's training, the cyclic consistency loss function is introduced:  
\[L_{cyc}(G,F)=\mathbb{E}_{x\sim p_{\text{data }}(x)}[\parallel F(G(x))-x \parallel_{1}]+\mathbb{E}_{y\sim p_{\text{dasan }(y)}}[\parallel G(F(y))-y\parallel_{1}] \tag{5}\]  
The L1 norm constraints \(x\) and \(F(G(x))\), as well as \(y\) and \(G(F(y))\), are computed. The above cyclic consistency loss function compares images in pixel space, which is not  
Figure 1: The framework for the domain adaptation in image by transfer learning. sufficient to recover all texture information. Therefore, perceptual consistency loss function is introduced:  
\[L_{\text{per}}(G,F)=\parallel\phi(x)-\phi(F(G(x)))\parallel_{2}^{2}+\parallel\phi( y)-\phi(G(F(y)))\parallel_{2}^{2} \tag{6}\]  
where \(||\phi(x)-\phi(F(G(x)))\parallel_{2}\) is the standard \(L_{2}\) norm and \(\phi\) is the feature extractor.