## 3 System Design and Methods
### Network Architecture Design
#### 3.1.3 Distribution Alignment  
To further mitigate the challenges posed by distribution heterogeneity between the source and target domains, we have incorporated a crucial mechanism: maximum mean discrepancy (MMD). This strategic addition is designed to effectively align the probability distributions of data in both domains, thus enhancing the model's performance in a transfer learning context. To delve into the specifics, our approach involves the computation of MMD, which serves as a non-parametric metric for quantifying the dissimilarity between probability distributions. This measure plays a pivotal role in quantifying the extent of divergence or alignment between the distributions of the transformed data originating from the source and target domains. What sets our approach apart is the utilization of not only labeled samples but also the substantial pool of unlabeled data instances found within the target domain. This innovative strategy allows us to harness the wealth of unlabeled data for the purpose of computing cross-domain MMD, effectively leveraging a vast and previously untapped resource. During the training process, a key objective is to minimize the MMD value systematically. This optimization criterion serves as a guiding principle for the model, compelling it to actively align the probability distributions characterizing the two domains. Through this alignment process, the classification model is primed to generalize effectively, demonstrating robust performance when applied to unlabeled target data samples. This harmonization of distributions across domains serves as a critical bridge that allows the model to transfer knowledge seamlessly and adapt successfully to the intricacies of the target domain. The MMD is calculated as the distance of two centroids corresponding to two datasets, which is expressed as:  
\[\mathcal{Q}_{m}\big{[}\mathbf{\hat{X}}_{s},\mathbf{\hat{X}}_{t}\big{]}=\left\| \frac{1}{n_{s}}\sum_{i=1}^{n_{s}}\mathbf{\hat{x}}_{i}^{s}-\frac{1}{n_{t}}\sum _{i=1}^{n_{t}}\mathbf{\hat{x}}_{i}^{t}\right\|^{2}, \tag{12}\]  
where \(\mathbf{\hat{x}}_{i}^{s}\in\mathbf{\hat{X}}_{s}\) and \(\mathbf{\hat{x}}_{i}^{t}\in\mathbf{\hat{X}}_{t}\) are the transformed samples output by the corresponding projection networks. To more effectively align distribution, conditional distributions between domains can also be aligned via minimizing centroid distance between corresponding classes across domains. Though we only know a few labeled data in the target domain, we can apply a pseudo classification to the unlabeled samples by reusing the classification network \(f_{c}(\cdot)\). By using the pseudo classification for the unlabeled data, we compute the MMD over classes, i.e.,  
\[\mathcal{Q}_{c}\big{[}\mathbf{\hat{X}}_{s},\mathbf{\hat{X}}_{t}\big{]}=\sum_{k =1}^{c}\left\|\frac{1}{n_{s}^{k}}\sum_{i=1}^{n_{s}^{k}}\mathbf{\hat{x}}_{k,i}^ {s}-\frac{\sum_{i=1}^{n_{t}^{k}}\mathbf{\hat{x}}_{k,i}^{l}+\sum_{i=1}^{n_{t}^{ k}}\mathbf{\hat{x}}_{k,i}^{u}}{n_{t}^{k}+n_{t}^{k}}\right\|^{2}, \tag{13}\]  
where \(\mathbf{\hat{x}}_{k,i}^{s}\in\mathbf{\hat{X}}_{s}\), \(\mathbf{\hat{x}}_{k,i}^{l}\in\mathbf{\hat{X}}_{t}\) are the labeled projected data samples belonging to the \(k\)th class of the source and target domain, while \(\mathbf{\hat{x}}_{k,i}^{u}\in\mathbf{\hat{X}}_{u}\) is the data sample of the \(k\)th pseudo class of the target domain. Correspondingly, \(n_{s}^{k}\), \(n_{t}^{k}\), and \(n_{u}^{k}\) are the number of samples of the \(k\)th class. This approach helps to capture underlying similarities and differences between the classes, contributing to the overall improvement in transfer learning performance. Instead of assigning hard labels according to the pseudo classification result, soft labeling assigns probability distributions over classes to each unlabeled sample, which results in a more stable iteration process and avoids negative transfer.