# An Adaptive Generative Adversarial Network for Cardiac Segmentation from X-ray Chest Radiographs
## 2 Basic Theories and Methods Related to the Proposed AGAN  
### Segmentation of Images Using Neural Networks  
An artificial neural network is an algorithm that simulates the human visual nervous system. A convolutional neural network is a deep learning algorithm built on traditional artificial neural networks [25]. It is also the first learning algorithm to be successfully used to train a multilayer network. A convolutional neural network includes an input layer, convolutional layers, downsampling layers (also known as pooling layers), connected layers and an output layer, as shown in Figure 1[26].  
The input to a convolutional neural network applied for image segmentation is usually the original image, with the pixel value as the minimum unit; this input is represented by \(X_{0}\) in this paper. In addition, \(H_{i}\) is used to represent the feature map of the \(i\)th layer of the convolutional neural network; specifically, the feature map of the first layer is \(H_{0}=X_{0}\). Under the assumption that \(H_{i}\) corresponds to a convolutional layer, \(H_{i}\) can be generated as shown in (1).  
\[H_{i}=f(H_{i-1}\otimes W_{i}+b_{i}) \tag{1}\]  
where \(W_{i}\) represents the weight vector of the convolution kernel in the \(i\) layer and the operator \(\otimes\) represents a convolution operation performed on the convolution kernel with the feature map from the (_i_-1)th layer. The output of the convolution is then added to the offset vector \(b_{i}\) of the _i_th layer. Finally, the feature map \(H_{i}\) of the _i_th layer is obtained through the nonlinear excitation function \(f(\star)\).  
After image convolution is completed as shown above, to reduce the dimensionality of the feature map and maintain its feature size invariant to a certain extent, the feature map needs to be downsampled in accordance with certain rules. Suppose that a downsampling layer follows the convolutional layer \(H_{i}\), as shown in (2).  
\[H_{i}=downsampling(H_{i}) \tag{2}\]  
After the image features in the convolutional neural network are alternately transferred in the depth direction through multiple convolutional layers and downsampling layers, a connected layer is used to classify the extracted features. For cardiac image segmentation, there are only two classes, namely, cardiac and noncardiac regions, which are represented by \(l_{j}\) (_j_ = 1, 0). The probability distribution of each class is represented by \(Y(j)\). The complete mathematical model that maps the original feature image to these two classes through a deep network can be written as shown in (3).  
\[Y(j)=P(L=l_{j}\big{|}H_{0};(W,b)) \tag{3}\]  
To train a convolutional neural network, the parameters (\(W\) and \(b\)) are determined by calculating and minimizing the loss between the results output by the network and the expected results. Common loss functions include the mean squared error (MSE) function (4) and the negative log likelihood (NLL) function (5).  
\[MSE(W,b)=\frac{1}{|Y|}\sum_{j=1}^{|Y|}\left(Y(j)-\hat{Y}(j)\right)^{2} \tag{4}\]  
\[\text{NLL}(\text{W},\text{b})=-\sum_{j=1}^{|Y|}\log Y(j) \tag{5}\]  
During training, a commonly used optimization method for neural networks is the gradient descent method. The residuals are backpropagated through gradient descent, and the trainable parameters (\(W\) and \(b\)) of the convolutional neural network are updated layer by layer. The intensity of backpropagation is controlled by the learning rate parameter (\(\eta\)). The relevant formulas are expressed as shown in (6) and (7).  
\[W_{i}=W_{i}-\eta\frac{\partial E(W,b)}{\partial W_{i}} \tag{6}\]  
\[b_{i}=b_{i}-\eta\frac{\partial E(W,b)}{\partial b_{i}} \tag{7}\]  
Figure 1: The structure of a convolutional neural network.