# Attention Score Enhancement Model Through Pairwise Image Comparison
## 2 Materials and Methods
### Attention Score Map Median Cosine Similarity (ASMS)  
Figure 4 illustrates the process of the Attention Score Map Median Cosine Similarity (ASMS) comparison between the training and reference images. This figure demonstrates how cosine similarity is computed in a vectorized space between the two attention score maps. The attention score map for the training image is shown in red, and for the reference image, in green. The ASMS is calculated as the average cosine similarity across patches, providing a quantitative representation of visual feature similarity between the training and reference images. Cosine similarity measures the similarity between two vectors based on the angle between them, disregarding their magnitudes. This metric is especially suitable for visual data comparison because it focuses on directional similarity. A cosine similarity close to 1 indicates that the vectors point in the same direction, while a value close to 0 signifies orthogonality. In this study, cosine similarity is chosen as it captures the directional properties of attention score maps, which are more important than magnitude for assessing feature similarity. This enables the model to evaluate the degree of similarity in visual features between the training and reference images. Figure 3: Pairwise Attention Enhancement (PAE) structure. ASMS: Attention Score Map Median Cosine Similarity. (**a**) Reference Image Encoding, (**b**) Attention Score Enhancement, (**c**) Learning Image Encoding. ASMS is pivotal in the Patch Attention Enhancement (PAE) model. Before merging the attention maps of two images, the PAE model evaluates their similarity and decides on merging based on this evaluation. The reference image's attention map is only merged with the training image if the cosine similarity exceeds a certain threshold, ensuring that the model only enhances attention between visually similar image pairs. This selective merging allows the model to capture subtle differences in local features more effectively by learning from images with shared visual characteristics. A higher ASMS value indicates high similarity between the attention maps of the two images, allowing the model to refine its feature learning by reinforcing attention in these regions. Furthermore, ASMS directly contributes to improving model performance. A high ASMS implies significant similarity between the training and reference images, enabling the model to integrate key visual features from both images, resulting in a richer representation. This approach allows the model to capture more precise visual patterns than learning from a single image alone. Enhanced attention maps are particularly beneficial for datasets where differences in local features are critical, such as cognitive impairment data. By reinforcing attention through ASMS, the PAE model retains the global learning capacity of the Vision Transformer (ViT) while enhancing the precision of local feature learning. ASMS quantifies similarity and enables the model to gain a deeper understanding of the visual characteristics of both images. For example, when the reference image's attention score vector is highly similar to that of the training image, the PAE model integrates shared visual features, leading to enriched learning. This is especially advantageous for datasets with diverse visual transformations, as it helps the model maintain consistent performance regardless of varying conditions. In cases where the ASMS is low, the model determines an insufficient similarity between the reference and training images and does not proceed with merging. This selective merging prevents learning from dissimilar patterns, reducing the risk of erroneous feature integration. Thus, ASMS is a critical mechanism for enhancing the model's accuracy and reliability, minimizing unnecessary information merging, and improving learning efficiency. Attention reinforcement based on ASMS is a key factor that enables the PAE model to achieve higher classification performance than the ViT.