# Domain Adaptation for Satellite-Borne Multispectral Cloud Detection
## 6 Adapting the Cloud Detector to the Target Domain
### Bandwidth-Efficient SDA  
To solve Problem 1 in Section 3.3.1, we leveraged the Fisher-Induced Sparse uncHanging (FISH) Mask [80] to select a small (or sparse) subset of \(\theta^{s}\) denoted by \(\widehat{\theta}^{s}\) (i.e., \(\widehat{\theta}^{s}\subset\theta^{s}\)) that are considered to be the \"most important\" weights to update during the adaptation process. The \"most important\" weights are those with significant empirical Fisher information, which, as per Equation (4), is a sum of the squares of gradients. Large gradients indicate that adjustments to these weights cause significant changes in the loss function. Therefore, updating these weights will likely reduce loss and improve model performance.  
First, as per Algorithm 1, we measured the empirical Fisher information (vector) of \(\theta^{s}\):  
\[F_{\theta^{s}}=\frac{1}{\left|\mathcal{D}_{\text{TH70}}^{t}\right|}\sum_{(x_{ j}^{s},y_{j}^{s})\in\mathcal{D}_{\text{TH70}}^{t}}\left(\
abla_{\theta^{s}}L \left(f^{g}(x_{j}^{t};\,\theta^{s}),y_{j}^{t}\right)\right)^{2}, \tag{4}\]  
where \(\left|\mathcal{D}_{\text{TH70}}^{t}\right|\) is the total number of training samples of \(\mathcal{D}_{\text{TH70}}^{t}\), and \(\
abla\) is the gradient operator. Recall that \(f^{g}(\cdot\,;\,\theta^{s})\) is the ground copy of the source cloud detector. Equation (4) computes the vector \(F_{\theta^{s}}\in\mathbb{R}^{|\theta^{s}|}\), and the importance of \(\theta^{s}_{k}\in\theta^{s}\) is represented by a large value \(F_{\theta^{s}_{k}}\). Then, given a desired _mask sparsity level_\(l\), the subset \(\hat{\theta}^{s}\) was obtained by selecting weights with the top \(l\)-highest Fisher values (i.e., the \"most important\" weights):  
\[\hat{\theta}^{s}=\left\{\theta^{s}_{k}\Big{|}F_{\theta^{s}_{k}}\geq\texttt{ sort}(F_{\theta^{s}})_{l}\,\right\}. \tag{5}\]  
Next, \(\hat{\theta}^{s}\) was updated on \(\mathcal{D}^{t}\) as  
\[\hat{\theta}^{t}=\operatorname*{arg\,min}_{\hat{\theta}^{s}}\sum_{(x_{j}^{t}, y_{j}^{t})\in\mathcal{D}_{\text{TH70}}^{t}}L\left(f^{g}(x_{j}^{t};\,\theta^{s}),y_{j}^ {t}\right), \tag{6}\]  
while the remaining weights \(\hat{\theta}^{s}=\theta^{s}\setminus\hat{\theta}^{s}\) were frozen. Lastly, \(\theta^{t}\) was obtained by setting \(\theta^{t}=\hat{\theta}^{t}\cup\hat{\theta}^{s}\). This algorithm allows us to uplink only \(\hat{\theta}^{t}\) to update \(f^{d}\).  
```
for\(i=1\) to \(|\theta^{s}|\)do\(\triangleright\theta^{s}\) are parameters of \(f^{g}\) \(F_{\theta^{s}_{i}}\gets 0\)\(\triangleright\) Initialise \(i\)th element of empirical Fisher information vector \(F_{\theta^{s}}\) for\(j=1\) to \(\left|\mathcal{D}_{\text{TH70}}^{t}\right|\)do  Get sample \(x_{j}^{i}\) and associated ground-truth label \(y_{j}^{t}\) \(F_{\theta^{s}_{i}}\gets F_{\theta^{s}_{i}}+\left(\
abla_{\theta^{s}_{i}} L\left(f^{g}(x_{j}^{t};\theta^{s}),y_{j}^{t}\right)\right)^{2}\) endfor \(F_{\theta^{s}_{i}}\gets F_{\theta^{s}_{i}}/\left|\mathcal{D}_{\text{TH70}}^ {t}\right|\) endfor \(\hat{\theta}^{s}\leftarrow\) parameters corresponding to the \(l\) largest elements of \(F_{\theta^{s}}\triangleright l\) is mask sparsity level \(\hat{\theta}^{t}\leftarrow\) solution of Equation (6) \(\theta^{t}\leftarrow\hat{\theta}^{t}\cup(\theta^{s}\setminus\hat{\theta}^{s})\)\(\triangleright\)\(\theta^{t}\) gets uplinked to update \(f^{d}\)
```  
**Algorithm 1** Bandwidth-efficient SDA using FISH MaskThe computational complexity associated with Equation (4) is \(O(|\theta^{s}|\cdot\left|\mathcal{D}_{\text{TH70}}^{t}|\right)\) differentiation operations. The computational complexity of Equation (5) is negligible compared to that of Equation (4). Thus, excluding forward propagation and backward propagation, the computational complexity of the FISH Mask algorithm is \(O(|\theta^{s}|\cdot\left|\mathcal{D}_{\text{TH70}}^{t}|\right)\) differentiation operations.  
We show in Section 8.2.1 that updating only 25% of the total weights of CloudScout, or 1% of the total weights of ResNet50, is sufficient to achieve similar levels of performance as updating 100% of the weights.