# Adaptation to CT Reconstruction Kernels by Enforcing Cross-Domain Feature Maps Consistency
## 2 Method
### Domain Adversarial Neural Network  
Further, we detail the methods that work with the unlabeled pool of data \(S_{2}\). As mentioned at the beginning of the section, the problem can be reformulated as unsupervised domain adaptation. The most successful approaches to this problem are based on adversarial training. Therefore, we adopt the approach of [15] and build a _domain adversarial neural network_ (DANN).  
DANN includes an additional domain classifier or discriminator which aims to classify images between the source and target domains using their feature maps. We train the model to minimize the loss on the primary task (segmentation) and simultaneously maximize the discriminator's loss. Thus, the segmentation part of the model learns domain features that are indistinguishable from the discriminator. The latter should improve the performance of the model on the domain.  
The original DANN architecture consists of three parts: (i) feature extractor \(H_{f}\), the part of segmentation model that maps input images \(x\) into the feature space; (ii) segmentation head \(H_{p}\), the complement part of segmentation model that predicts binary mask \(\hat{y}=H_{p}\Big{(}H_{f}(x)\Big{)}\); and (iii) discriminator \(H_{d}\), the separate neural network that predicts domain label \(\hat{d}=H_{d}\Big{(}H_{f}(x)\Big{)}\). In Figure 1, \(H_{f}\) and \(H_{p}\) correspond to the encoder and decoder parts of the model, respectively. \(H_{d}\) is denoted with the dashed green arrow that passes the aggregated features to the adversarial loss.  
Following [15], our optimization target is  
\[E(\theta_{f},\theta_{p},\theta_{d}) =\sum_{i=1}^{N_{s}}L_{s}(H_{p}(H_{f}(x_{i};\,\theta_{f});\,\theta _{p}),\,y_{i})\] \[-\lambda\sum_{j=1}^{N_{2}}L_{d}(H_{d}(H_{f}(x_{j};\,\theta_{f}); \,\theta_{d}),\,d_{j})= \tag{1}\] \[=\sum_{i=1}^{N_{s}}L_{s}(\hat{y}_{i},\,y_{i})\,-\,\lambda\sum_{j =1}^{N_{2}}L_{d}(\hat{d}_{j},\,d_{j})\] \[(\hat{\theta}_{f},\hat{\theta}_{p}) =\operatorname*{arg\,min}_{\theta_{f},\theta_{p}}E(\theta_{f}, \theta_{p},\theta_{d}),\] (2) \[\hat{\theta}_{d} =\operatorname*{arg\,max}_{\theta_{d}}E(\theta_{f},\theta_{p}, \theta_{d}), \tag{3}\]  
where \(L_{s}\) is the segmentation loss (BCE), \(L_{d}\) is the domain classification loss (BCE). \(\theta_{f}\), \(\theta_{p}\), \(\theta_{d}\) are the parameters of \(H_{f}\), \(H_{p}\), \(H_{d}\), respectively, and \(\hat{\theta}_{f}\), \(\hat{\theta}_{p}\), \(\hat{\theta}_{d}\) are the solutions we seek. Parameter \(\lambda\) regulates the trade-off between the \(L_{s}\) and \(L_{d}\) objectives.  
However, there is no consensus in the literature on how to connect the discriminator to a segmentation network [30]. We follow the findings [30] that the earlier U-Net layers contain more domain-specific information than the later ones and use features from the encoder layers as input to the discriminator. Our preliminary experiments also confirm that using encoder features is a better strategy. We detail this approach in Figure 1(6).  
We also modify the architectural design of DANN for the segmentation task. The goal of the discriminator is to classify a kernel that is used to reconstruct the image. To aggregate features before the discriminator, we use \(1\times 1\) convolutions and interpolation to equalize the number of channels and spatial size; then, we concatenate the result. The discriminator consists of a sequence of fully-convolution layers followed by several fully-connected layers. We also use Leaky ReLU [31] and average pooling to avoid sparse gradients.