Skip to main content

ml_dl.WaterUNet

ml_dl.WaterUNet(in_channels, n_classes=2, base=24)

Four-level U-Net with batch-norm for water-class segmentation.

Deeper architecture used by the water-classification notebook (notebooks/01_water_classification.ipynb). Four encoder levels + one bottleneck + three decoder levels with skip connections. With the default base=24 and three input channels the model has roughly 250,000 parameters and trains end-to-end in a few minutes on a laptop CPU.

Three pooling operations give the bottleneck a receptive field of roughly 32x32 input pixels, large enough to cover real river-bend and lakeshore geometry on 128x128 input tiles. Batch-norm after each convolution lets the optimiser converge with a higher learning rate.

Parameters

Name Type Description Default
in_channels int Number of input channels. For S2 + S1 fused cubes this is typically 6 (S2 B02, B03, B04, B08 + S1 VV, VH); with DEM derived-features it goes up to 8. required
n_classes int Number of output channels. Use 2 for binary water classification with CrossEntropyLoss (the convention in notebook 01); 1 for single-channel sigmoid-style output. 2
base int Number of filters in the first encoder block. Each level doubles: base, 2*base, 4*base, 8*base from enc1 through enc4. 24

Notes

Output is raw logits. The caller is responsible for any activation; CrossEntropyLoss and BCEWithLogitsLoss both consume logits directly.