## 5 Materials and Methods
### Contrastive Semantic Alignment
(**c**) t-SNE visualization of the Brinke and Meratnia dataset. ### Configuration and Hyperparameter Tuning

Inspired by the foundational work of [67], we initiated our model simulations using the same hyperparameters as those employed in their study in order to establish a consistent baseline for comparison. The architecture begins with a shared sub-network based on a pre-trained ResNet50 [80], which outputs a feature space of size \((1,1,2408)\). This shared sub-network leverages the robustness of ResNet50, trained on the ImageNet 2012 dataset, to extract generalized features applicable across different domains. #### 6.2.1 Domain-Specific Feature Extractors

For each domain-specific task, the feature extractor comprises a combination of convolutional layers. Specifically, it includes two \(2D-CNN(1\times 1)\) layers and one \(2D-CNN(3\times 3)\) layer, followed by an average pooling layer of size \((7,7)\). This configuration produces a refined feature space of size \((1,1,2042)\), as depicted in Figure 3. The inclusion of \(1\times 1\) convolutions helps with dimensionality reduction and fine-grained feature selection, while the \(3\times 3\) convolutional layer captures spatial relationships and patterns critical for domain-specific tasks. #### 6.2.2 Domain-Specific Classifiers

Each domain-specific classifier is implemented as a three-layer fully connected network, structured as \(2042\to 256\to K\) classes, where \(K\) represents the number of output classes for the specific domain, as depicted in Figure 4. A softmax activation function is applied to the final layer to output class probabilities. This structure ensures sufficient capacity for complex classification tasks while maintaining computational efficiency. #### 6.2.3 Grid Search for Optimal Configuration

To enhance model performance, we conducted a thorough grid search by varying key architectural components. These variations included modifying the number of output channels and kernel sizes in the \(2D-CNN\) layers as well as experimenting with deeper fully connected layers in the domain-specific classifiers. We also tested different batch sizes \((10,30,60)\) during training. Interestingly, despite extensive experimentation, the most optimal configuration remained aligned with the one proposed in [67]. The only significant improvement was achieved by replacing the cross-entropy loss function with negative log-likelihood loss (NLLoss), which provided a noticeable boost in classification accuracy. #### 6.2.4 Learning Rate Strategy and Optimization

Since the shared sub-network was pre-trained on ImageNet, its learning rate was set 10 times smaller than those for the domain-specific feature extractors and classifiers in order to preserve learned representations while allowing for fine-tuning. We tested learning rates in the range of \([0.0001,0.01]\). To further optimize training, we adopted a dynamic learning rate adjustment strategy based on [67]. The learning rate was updated after each epoch using the following formula:

\[LR_{new}=\frac{LR_{prev}}{(1+10*p)^{0.75}} \tag{17}\]

where \(p\) is a parameter that progresses linearly from 0 to 1 over the course of training, allowing for gradual refinement of the learning process, and 0.75 is set by the strategy design. #### 6.2.5 Optimization Algorithms

We evaluated several optimization algorithms, including

* Adaptive Moment Estimation (Adam): Known for its adaptive learning rate capabilities. * Adaptive Gradient Algorithm (Adagrad): Effective for sparse data scenarios. * Adam with Weight Decay (AdamW): Combines Adam's efficiency with weight decay for better regularization. * Stochastic Gradient Descent (SGD) with momentum (0.9): Provides stability and faster convergence by dampening oscillations. Among these, SGD with momentum yielded the best performance, balancing optimization speed and model generalization. #### 6.2.6 Early Stopping and Data Splits

To prevent overfitting and ensure robust model training, we implemented early stopping.