# A Novel Method for 3D Lung Tumor Reconstruction Using Generative Models
## 3 The Proposed Model
### Lung Segmentation
#### 3.1.1 Generator Architecture  
In our context, segmentation is treated as a task where each pixel in an image is classified as either part of the lung area or not. To perform this task, we rely on the precision of a U-Net-based generator network, as depicted in Figure 2. When processing a CT scan labeled \(I_{i}\), the generator network (G) meticulously evaluates each pixel to determine its association with the lung region, subsequently generating a mask \(M_{i}\) that accurately reflects this classification. The generator network has two principal components: the encoder and the decoder. The encoder, in its complex task, begins by taking the input image \(I_{i}\) and, through a series of convolution layers, extracts features at multiple scales. These layers enable the encoder to delve into the image, capturing a broad range of details and complex information from the image. Following the feature extraction, the decoder, playing a pivotal role, uses these multi-level features to construct the masks. By leveraging these features, the decoder can accurately reconstruct the intricate structures and contours of the lung area, resulting in detailed and precise masks. Both the encoder and decoder sections include convolution layers, which are crucial in neural network designs for identifying local patterns and spatial correlations, and are key elements for accurate segmentation. The generator network is designed as a binary pixel classifier, identifying each pixel as either part of the lung area (labeled as one) or not (labeled as zero). A significant challenge arises due to the overwhelming number of pixels labeled as zero, which is not associated with the lung area and leads to an imbalance. This imbalance causes the classifier to lean towards predicting pixels as non-lung areas, which can drastically reduce the model's ability to delineate the lung region accurately. To counteract this issue, the training strategy for the generator incorporates an RL algorithm. RL is based on reward and punishment mechanisms, making it an ideal solution for addressing the problem of imbalanced classification. Within this framework, the RL algorithm is customized to assign much higher rewards for accurately identifying pixels within the minority class (the lung region) than those for correctly classifying pixels in the majority class (non-lung area). Conversely, the penalties for incorrectly classifying lung region pixels are more stringent than errors made within the majority class. Despite their scarcity, this strategy shifts the model's focus towards more accurately recognizing and classifying pixels withinthe lung region. By amplifying the consequences for the minority class, the RL algorithm motivates the generator network to concentrate more on lung areas, thus mitigating the bias towards the more prevalent non-lung pixels. This adjustment not only equalizes the classifier's attentiveness to both classes but also significantly boosts the model's precision and effectiveness in segmenting lung regions from CT scans. The loss function for the generator is defined as follows [57]:  
\[\theta_{g}^{\prime}=\theta_{g}+\alpha\sum_{t=0}^{T}\
abla_{\theta_{g}}\log\pi_{ \theta_{g}}(a_{t}|s_{t})\overline{R_{t}} \tag{1}\]  
where \(\theta_{g}\) and \(\theta_{g}^{\prime}\) represent the parameters of the generator before and after training, respectively. \(\alpha\) is the learning rate, while \(T\) is a terminal time step. \(\
abla_{\theta_{g}}\) signifies the gradient with respect to the generator parameters. \(\log\pi_{\theta_{g}}(a_{t}|s_{t})\) is the logarithm of the policy defined by the generator parameters, which gives the probability of taking action \(a_{t}\) in state \(s_{t}\). \(\overline{R_{t}}\) represents the average reward received at time \(t\), calculated across all pixels, where \(R_{t}\) is defined as follows [58]:  
\[R_{t}(s_{t},a_{t},y_{t})=