## 2 Materials and Methods
### Optimizer Adjustment  
Although the proposed dynamic kernel mechanism enables multi-level feature extraction and enhances efficiency by reducing computational cost, optimization dynamics remain crucial to ensure stable convergence. The varying kernel sizes introduce changes in gradient updates, which necessitate an adaptive optimizer strategy to maintain robust learning across different feature representations. For this reason, an additional contribution of this work is the introduction of an optimizer-switching mechanism based on the IoU validation metric, combining the Adam optimizer [44] with the AMSGrad variant [45] and Nadam optimizer [46]. For the initial training epochs, Adam with AMSGrad is employed for its adaptive learning rate capabilities and enhanced convergence properties. Adam synergizes momentum-based and adaptive gradient methods by maintaining first-order (\(m_{t}\)) and second-order (\(v_{t}\)) moment estimates of the gradients, ensuring robust and efficient optimization. These moments are updated using exponential moving averages, as shown in Equation (4):  
\[\theta_{t}=\theta_{t-1}-\eta*\frac{\hat{m}_{t}}{\sqrt{\hat{v}_{t}+\epsilon}}\]  
\[m_{t}=\beta_{1}m_{t-1}+(1-\beta_{1})g_{t}\]  
\[v_{t}=\beta_{2}v_{t-1}+(1-\beta_{2})g_{t}^{2} \tag{4}\]  
\[\hat{m}_{t}=\frac{m_{t}}{1-\beta_{1}^{2}}\]  
\[\hat{v}_{t}=\max(\hat{v}_{t-1},\ v_{t})\]  
Here, \(g_{t}\) represents the gradient of the loss function with respect to the model parameters at step \(t\), while \(\hat{m}_{t}\) and \(\hat{v}_{t}\) are bias-corrected versions of \(m_{t}\) and \(v_{t}\), addressing initialization bias. The learning rate (\(\eta\)) is set to 0.001, with \(\beta_{1}=0.9\) and \(\beta_{2}=0.999\) as decay rates for the moments, and \(\epsilon\) is a small constant to prevent division by zero. AMSGrad modifies Adam by ensuring the second moment estimate \((\hat{v}_{t})\) does not decrease, stabilizing updates in non-convex optimization scenarios. This stabilization mitigates overshooting and ensures reliable convergence, which is particularly valuable in shadow detection tasks requiring precise feature extraction and segmentation. Additionally, \(\beta_{1}^{t}\) in the bias correction step refers to \(\beta_{1}\) raised to the power of \(t\), ensuring that the moving average does not remain biased towards zero in the early iterations of training. Furthermore, \(g_{t}^{2}\) denotes the element-wise square of the gradient vector, meaning that each component of \(g_{t}\) is squared element-wise to compute the second moment estimate \(v_{t}\). While Adam effectively achieves rapid convergence in the early epochs, it often results in stagnation in validation metrics during later stages. To address this issue, the proposed method switches to Nadam, a variant of Adam that incorporates Nesterov momentum, during the fine-tuning phase. Nadam enhances the optimization process by anticipating parameter updates through Nesterov acceleration, leading to faster convergence and smoother optimization trajectories. The key modification in Nadam is shown in Equation (5):  
\[\theta_{t}=\theta_{t-1}-\eta*\frac{\hat{m}_{t}+\beta_{1}*g_{t}}{\sqrt{\hat{v}_ {t}+\epsilon}} \tag{5}\]  
Here, the term \(\beta_{1}*g_{t}\) accounts for the Nesterov correction, which accelerates convergence and refines updates. This makes Nadam particularly suitable for the fine-tuning phase, as it complements Adam's broader learning phase with precise adjustments. The optimizer-switching mechanism is designed to address long-term stagnation in network training and is illustrated in Figure 6. The process uses \(P_{o}\) (current performance metric) as input and \(P_{op}\) (patience parameter), set to 25 in this study. If the training process fails to yield significant improvements over \(P_{op}\) consecutive epochs, the mechanism triggersa switch from Adam with AMSGrad to Nadam. This transition facilitates further improvements in network performance with minimal computational overhead.