Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Encoder-decoder architectures with a regression head, and losses like MSE

The previous page established what changes conceptually between classification and regression. This page gets specific: which architectures actually work for regression, and which loss function to choose, before the next two pages prepare data and train a real model.


1. Motivation

You already know U-Net and its relatives from L07. The good news is that this knowledge transfers almost directly; the architectural shift from segmentation to regression is smaller than you might expect, which means most of your existing intuition still applies here.


2. Core idea

Encoder-decoder architectures built for segmentation, U-Net, UNet++, DeepLabV3+, and Feature Pyramid Network (FPN), all work for regression with minimal modification. The encoder still extracts multi-scale features, the decoder still reconstructs spatial detail, and skip connections still preserve the fine-grained detail needed for precise per-pixel output. The real change is concentrated in the output head and the loss function, not the backbone itself.


3. What actually changes

A. Reusing the encoder-decoder pattern

Everything you learned about the encoder-decoder architecture pattern in L07 still applies directly: the encoder compresses the input into features, the decoder reconstructs them back to full spatial resolution, and skip connections keep the fine spatial detail that a heavily compressed bottleneck alone would lose. Precise per-pixel regression values need exactly the same spatial precision segmentation boundaries did, which is why skip connections matter just as much here.

B. The output head

A segmentation model ends in N output channels (one per class) followed by softmax. A regression model ends in a single output channel, with no activation function, or a ReLU activation when the target is known to be non-negative, such as height or biomass, where ReLU simply prevents the model from predicting an impossible negative value. geoai handles this switch automatically: setting up a regression task configures the underlying architecture with a single output channel rather than requiring you to modify the architecture yourself.

C. Choosing a loss function

Three loss functions cover most regression use cases:

geoai exposes all three through a loss_type parameter ("mse", "l1", "huber"), so switching between them is a one-line change, the same low-cost experimentation pattern you have seen for architecture and encoder choices in earlier lessons.

D. Valid ranges and clipping

Many regression targets have a known physical range: NDVI falls between −1 and 1, heights and biomass cannot be negative. You can enforce this domain knowledge in two places: filtering target values during tile creation, and clipping predicted values during inference. Both are covered in more detail on the data-preparation and inference pages ahead; the important idea here is that combining both, rather than relying on either alone, produces the cleanest results, since the model learns approximate bounds from clean training data while inference-time clipping catches the occasional out-of-range prediction at the edges.


4. Python reactivation

No new Python syntax here. This page is a decision-making guide for two parameters, architecture/encoder_name and loss_type, you will set directly when calling geoai.train_pixel_regressor() two pages from now.


5. Common pitfalls


6. Mini task

Your project predicts soil organic carbon content, a non-negative quantity, from imagery paired with soil-sample lab measurements that are known to include occasional measurement errors. Which loss function would you start with, and what output activation would you use? Justify both choices.

Sample solution

Huber loss is a reasonable starting choice, since it behaves like MSE for the (presumably) majority of well-behaved measurements while reducing sensitivity to the occasional labeling error, exactly the noisy-reference-data situation Huber is suited for. For the output activation, a ReLU makes sense, since soil organic carbon content cannot be negative, and ReLU enforces that constraint directly in the model’s output rather than relying on post-hoc clipping alone.


7. Key takeaways

Further reading