# AI Approaches in Computer-Aided Diagnosis and Recognition of Neoplastic Changes in MRI Brain Images
## 2 Materials and Methods  
### Convolutional Neural Networks and Grad-CAM Visualization  
Convolutional Neural Networks are currently the state-of-the-art solution for most artificial intelligence tasks related to images. This architecture is a root for Deep Learning due to its ability to learn a hierarchical representation of the data, which made it possible to skip the feature extraction part--an indispensable step in classical machine learning. CNNs use a convolution kernel instead of a vector of connection weights to roll over a picture to extract local relations between pixels. Further convolutional layers do the same thing on the outputs from previous ones, extracting more globally-oriented features in each layer [12]. This approach allows for the creation of high-level image representations that the classifier can use to make decisions. Due to the large number of different convolution kernels learned by the network, provided the dataset contained suitable samples, the algorithm is also translation, scale, and rotation invariant [18]. While powerful, CNNs, as most Neural Network algorithms, lack interpretability. It is hard to tell why the network made a specific decision, which is unacceptable in the case of a CAD system. Fortunately, some algorithms allow visualizing the inner workings of a CNN. One way to visualize the network's inner workings is to synthesize an input that maximizes the layer's activation, showing what features this neuron has learned [19]; this method is called Activation Maximization and is presented on the left in Figure 1. This approach is excellent when it comes to understanding what a CNN's layer \"sees\", but it does not help to judge why a particular input has been marked as a specific label. When considering reasons behind a decision regarding a specific input, one of the most popular visualization methods is Grad-CAM, also presented in Figure 1 on the right. Figure 1: An Activation Maximization (on the **left**) and Grad-CAM visualization (on the **right**) examples of a CNN trained to classify brain tumors. As seen in Figure 1, the advantage of the Grad-CAM method is that it is input-specific; it does not answer the question of \"how\" the neural network resolved the problem but which areas of the image influenced the response the most. An added advantage of this algorithm is that it does not have to mark areas responsible for the actual response; it can create a visualization of all the classes learned by the network. It might be instrumental in a CAD system, for example, in the case of non-tumor classification to highlight suspicious areas resembling tumors about which the network was unsure. The name of the algorithm explains the idea behind it. Grad-CAM stands for: \"Gradient Weighted Class Activation Mapping\", which means that the importance of every pixel is calculated based on the gradients of the given output class relative to feature activation maps of the last convolutional layer. Every convolutional layer in the network operates on several filters, producing a single feature map (mostly a two-dimensional table). These feature maps are then flattened and used by the classifier (usually a fully-connected neural network) to calculate the response of the whole network. For every value in these feature maps, the gradient can be calculated using the weights of the classifier. These gradients are then normalized, and a weighted point-wise mean of feature maps is calculated, with the sum of gradients used as a weight. The result of these computations is a single, averaged feature map that can be treated as an image. This image then can be upscaled to the size of the input and superimposed with it, creating a heatmap, where high values of the resulting feature map indicate the great importance of the pixel and low values reveal that the pixel was not relevant for the result. In Figure 1, high pixel importance is presented using red, while non-important pixels are painted blue, and such an approach shall continue later in the work.