## 3 Materials and Methods
### Neural Network Architecture  
The neural network architecture developed in this work has four stages (Figure 4). S0 is characterized by the initial convolutions, and S1 with the first dense block and transition layer of the DenseNet-201, pre-trained on ImageNet. The others, S2 and S3, were targeted by block combinations. The resulting versions were compared regarding their performance in classifying medical images. Dense blocks are derived from DenseNets, which emerged as an effective solution to tackle the vanishing gradient problem in deep neural networks. Each DenseNet comprises several dense blocks containing convolutional operations and direct connections between layers. These connections, similar to those present in ResNets [36] but using concatenation instead of summation, allow knowledge to be shared more efficiently between layers. Furthermore, each dense block is separated by a transition layer composed of a convolution layer and a pooling layer (Figure 5), which reduces the resolution of the generated feature maps, preparing them to be processed through subsequent layers. \begin{table}
\begin{tabular}{c c c} \hline
**Category/Magnification** & **40\(\times\)** & **100\(\times\)** \\ \hline Normal & 42 & 42 \\ Cancer (squamous cell carcinoma) & 55 & 55 \\ \hline
**Total** & **97** & **97** \\ \hline \end{tabular}
\end{table} 
Table 2: Distribution of images from PCPAm according to magnification and pathological classification. Figure 4: Neural network architecture developed in this work. MBConv blocks (Figure 6) [37, 38], derived from depthwise convolutions, are particularly efficient for capturing spatial interactions. The key feature of these blocks is the \"inverted bottleneck\" design, which expands the input channel size by four times and subsequently projects this expanded state back to the original channel size, allowing a residual connection. This technique is similar to the FFN (Feed-Forward Network) module found in Transformers, where a fully connected layer expands and reduces the number of channels, facilitating gradient propagation and learning in very deep networks [14]. In addition to the inverted bottleneck design, MBConv blocks in EfficientNet incorporate the Squeeze-and-Excitation (SE) [38, 39] mechanism, which is essential for improving the network's efficiency in capturing relationships interdependent between channels. SE squeezes spatial information globally, condensing the information into a single dimension per channel. Next, an excitation phase occurs, where weights are learned to highlight the most relevant channels selectively, amplifying the most valuable features for the specific task. This process allows the network to adapt to the most essential characteristics dynamically, improving generalization capacity and performance with a minimal increase in computational cost. Transformer blocks (Figure 7) [23] are structured to capture global relationships between image patches using self-attention mechanisms. Each block comprises four main components: a normalization layer (Layer Norm), a multi-head attention layer, a second normalization layer, and an MLP layer (Multi-Layer Perceptron). The multi-head attention layer allows the model to consider different aspects of spatial relationships when computing similarity weights between patches, generating attention maps that help the network focus on essential areas of the image. Additionally, two residual connections are implemented to ensure that information flows efficiently across layers, helping maintain model stability during training and facilitating gradient pr  
Figure 5: An example of a Dense block and a transition layer from DenseNet architecture. Figure 6: An example of an MBConv block. Using these blocks, we developed six neural network architectures. In stages S0 and S1, the architectures consist of the initial layers from a pre-trained DenseNet, which we refer to as \"I\". Following this, we have a dense block with a transition layer, denoted as \"D\".