Decoders

Decoders are the dense trainable component: the dense-grid analogue of Aggregators. Where an aggregator collapses a bag of tile features into a single slide- or patient-level vector, a decoder consumes the dense (d, grid_h, grid_w) token grid a frozen foundation-model encoder emits and produces a dense per-position output (a per-pixel segmentation map or a per-class detection heatmap). No gradients flow through the backbone; only the decoder is trained.

The dense paths share the same front half — a frozen encoder produces a dense (d, grid) grid (cached as feature_type="dense_grid") — and differ only in the trainable component on that grid and its output representation. The decoder is the default trainable component; the decoder-free pixel-classifier method is the alternative.

Decoding methods

  • linear — a single 1x1 conv at grid resolution (the minimal dense linear probe).

  • lightweight_conv — the default trainable neural decoder (documented below).

  • heavy_conv — a UPerNet/DPT-lite decoder: pyramid-pooling context fusion + learned (transposed-conv) upsampling. Like lightweight_conv it opens with a 1x1 d->D projection, so its trainable capacity is independent of the encoder’s embedding dim d (the same fairness invariant powers the multi-encoder Composite ensemble, where the projection absorbs the concatenated Σdᵢ width).

  • Decoder-free pixel classifier — classifies the encoder’s own attention per pixel, no neural decoder: Attention-based segmentation · tutorial.

lightweight_conv

lightweight_conv is the default decoder. It regresses a (C, grid) map from the dense token grid; the task head then interpolates it to the supervision target_size, crops via crop_box, and applies the task-specific activation (a sigmoid per-class heatmap for detection; per-pixel class logits for segmentation).

decoder:                               # the dense trainable component
  name: lightweight_conv

The decoder is input-agnostic: it consumes whatever dense (d, grid) grid the encoder emits, set by preprocessing.feature_kindpatch_features (the ViT patch-token grid, d = the encoder’s feature dim) or cls_attention (per-head prefix-token self-attention as a (K, grid) grid). Switching between them is a pure config flip — the decoder is simply built with input_dim set to the emitted channel count (d or K). Multi-encoder Composite runs are supported and auto-concatenate at token-grid resolution (concat_resolution: grid).