## 5 Establishment, Training, and Testing of Deep Learning Model
### Model Training and Hyperparameter Optimization  
The experiments in this study were conducted on a professional workstation running the Windows 10 operating system, equipped with a 12 th Gen Intel(R) Core(TM) i9-12900 KF CPU (Intel, Santa Clara, CA, USA) and two NVIDIA RTX 3090 GPUs (Nvidia, Santa Clara, CA, USA). All algorithms were implemented in Python 3.9, with the K-means clustering algorithm based on the scikit-learn library and the UNet algorithm built upon the PyTorch 2.4.0 framework. The UNet hyperparameters were configured as follows: epochs set to 50; batch size set to 8; initial learning rate of 0.0001, which decayed to 0.00001 after 30 training epochs; the loss function employed Dice Loss to adequately account for class imbalance (where contaminated areas represent a relatively small portion of the entire site); and during training, image-label pairs were randomly horizontally or vertically flipped with a 50% probability to enhance model robustness and ensure optimal training outcomes. The training process is illustrated in Figure 16. The loss function decreased sharply during the first 5 epochs, exhibited fluctuating declines between epochs 6-25, and gradually converged thereafter. Conversely, the IoU metric showed rapid initial improvement in the early epochs, followed by fluctuating increases until stabilization. These training dynamics demonstrate that the UNet model successfully converged on our custom dataset. Based on testing conducted with the trained UNet model, the evaluation results are as follows: mIoU reached 86.58%, Acc achieved 99.42%, Pre attained 75.72%, Rec reached 76.80%, and f1 registered 76.23%. Additionally, this study evaluated the inference speed of UNet on contaminated soil resistivity images, obtaining a processing rate of 15.51 images per second. These results demonstrate UNet's exceptional suitability for automated segmentation tasks in contaminated site identification, exhibiting outstanding accuracy and efficiency. Qualitative testing results of the model are shown in Figure 17. The segmentation outputs from UNet show high consistency with the actual contaminated areas, further validating the model's superior contamination identification performance. To further validate the optimal selection of two core hyperparameters in the UNet training process, learning rate, and batch size, a series of hyperparameter optimization experiments were conducted, with results documented in Table 1. The initial learning rate was tested at three values, 0.0001, 0.001, and 0.01, while the batch size, determined by the workstation configuration, was evaluated at 8, 4, and 2. It should be noted that after 30 training epochs, the learning rate was adjusted to 1/10 of its initial value for each configuration. When employing a smaller initial learning rate (0.0001) with a batch size of 8, the model achieved optimal performance (mIoU 86.58%). As the learning rate increased to 0.001 and 0.01, mIoU decreased by 3.64% and 7.28%, respectively, while f1 declined by 2.57% and 6.49%, indicating that excessively large learning rates destabilize the optimization process. Notably, with a fixed learning rate of 0.0001, reducing the batch size from 8 to 4 had a limited impact on accuracy (0.24% mIoU reduction), but further reduction to 2 caused significant performance degradation (3.10% mIoU decrease). This demonstrates that moderate batch sizes help maintain gradient update stability. Experimental results confirm that for contaminated site segmentation tasks, the UNet model exhibits considerable sensitivity to hyperparameter configuration. The best practice is to use a small learning rate (0.0001) with a large batch size (8). Figure 16: Training process of UNet on the custom dataset. Figure 17: Segmentation results of UNet on a typical training sample. Further investigation examined the impact of the model's encoder on segmentation performance. While the UNet architecture, shown in Figure 15, employs VGG-16 as its encoder, we additionally considered VGG-13 and VGG-19 configurations.