## 3 Materials and Methods
### Vision Transformer (ViT)  
Transformers are deep neural networks initially used in the field of natural language processing. Due to their powerful capabilities, transformer-based models have often performed similarly to or better than other types of networks, such as CNNs and RNNs, in visual benchmarking studies [33]. The ViT divides each image into small patches. These patches are flattened according to their positional order and each patch is represented at a certain size. Positional encoding is used in ViT to preserve the order of the patches, allowing for the model to learn the relationship of each patch with others. ViT models use the self-Attention mechanism (SAM) to understand the context between distant pixels in the image. This enables the model to evaluate the relationship between any two points in the image. Structurally, the inter-layer SAM allows for each patch to establish relationships with all other patches, supporting more global feature learning. The structure of the ViT architecture used in this study is shown in Figure 4.  
CNNs use convolutional layers to capture spatial hierarchies in images. These layers apply small local filters to learn features. Low-level features, such as basic edges and textures, are learned in the initial layers, while more complex patterns are captured in deeper layers. Structurally, CNNs have a flat hierarchy, meaning that larger, global features are represented upon moving up to the top layers. As a result, CNNs are able to work quickly and effectively on smaller datasets and are particularly successful at detecting local patterns. They are widely used, with their structures optimized for TL. In contrast, ViT models can learn more complex relationships and achieve very high accuracies when trained on large datasets with high computational power. In particular, the performance of ViT models offers a significant advantage in tasks that require modeling global relationships.  
In this study, an image classification model is developed to perform PCa classification using the ViT architecture. Unlike traditional CNN-based classification approaches, the model divides the images into small patches, uses each patch as an input unit, and models the relationship of each patch with all other patches. First, the image data are rescaled and normalized to a specified size of 150 \(\times\) 150 pixels and then divided into patches. These patches are connected through the SAM used in the ViT model to learn global relationships within the image. The model passes through layers that include attention layers and multi-layer perceptron (MLP) blocks for each patch. The Transformer block essentially consists of two main components: multi-head self-attention and the MLP block. First, self-attention learns the relationships between different regions (patches) of the image, thereby capturing global features. After this stage, the MLP block further enriches the representation of each patch by processing the output of the attention mechanism.  
In the construction of the ViT classifier model, transformer blocks equipped with multi-layer attention and residual connections are built using patch-based image representations. In the model, MLP blocks are used to learn certain non-linear transformations, and the classification layer is adapted for binary classification with a sigmoid activation function. The model, compiled with the Adam optimization algorithm and binary cross-entropy loss function, is trained for 10 epochs with 10% validation data.