betaFeedback

WorksComputer Science

CanopyFormer: Attention-Guided SegFormer for Explainable Forest Cover Segmentation

Abstract

In transformer segmentation models, attention is usually visualized after training rather than supervised. Although attention supervision has been explored for natural images and driving scenes, aerial forest segmentation typically uses attention only as an architectural component and evaluates interpretability qualitatively. We present CanopyFormer, an attention-guided SegFormer-B0 that uses an Attention Consistency Loss to align attention with the ground-truth forest mask, encouraging attention to focus on canopy regions. Since SegFormer uses spatial-reduction attention, we adapt Gradient-weighted Attention Rollout by restricting it to the final encoder stage, where the attention matrix is square. We introduce Average Attention-Mask Overlap (AAMO) to measure attention alignment and incorporate a deletion test to evaluate faithfulness. On 5108 images, our method increases AAMO from 0.0334 to 0.7476, approximately 22 times the vanilla SegFormer-B0 result, with a modest decrease in Dice score from 0.8743 to 0.8577. The deletion test reveals that improved alignment does not necessarily translate into improved faithfulness: removing the most-attended 25% of patches reduces the forest score by 12.1%, compared with 33.0% when removing random patches. Attention supervision introduces no additional inference cost, although double backpropagation makes each training step 2.6 to 2.8 times slower. The attention alignment improvement also generalizes to a second dataset, LoveDA. Additionally, a Boundary Refinement Module provides no consistent Dice improvement and reduces AAMO, while mean squared error substantially outperforms Kullback-Leibler divergence as the attention loss.

Introduction

Forest-cover segmentation from aerial and satellite imagery supports ecological monitoring, deforestation tracking, and land management, and up-to-date land-cover and land-use maps underpin regional planning [1]. Convolutional neural networks (CNNs) such as U-Net [2] long dominated the task, and transformers such as SegFormer [3] are now adopted for their long-range context. However, most segmentation work, including recent forestry studies [4, 5, 6], uses attention only to improve accuracy and judges explainability, if at all, by inspecting heatmaps after training. A review confirms this: over 90% of remote-sensing explainable artificial intelligence (XAI) studies evaluate explanations only anecdotally [7].

Because attention is not guided during training, it can drift to task-irrelevant regions such as image corners (Figure 5) instead of forest, which undermines trust in the model’s explanations. Existing studies do not quantitatively evaluate the alignment or faithfulness of attention in forest segmentation.

Input tile, ground truth, Vanilla SegFormer-B0 attention, CanopyFormer attention, and CanopyFormer prediction

Figure 5. Vanilla and CanopyFormer attention on a test tile.

Mask alignment is how well the thresholded attention map overlaps the ground-truth forest mask. It measures how plausible the explanation is, and Average Attention-Mask Overlap (AAMO) quantifies it (Section IV). Attention faithfulness is how well the map reflects the regions the prediction actually depends on [8]: removing highly attended pixels should change the prediction more than removing others. Alignment does not imply faithfulness [9], so we test faithfulness separately with a deletion test (§ 6-E).

We use an XAI method inside the training objective, not only for visualization. Gradient-weighted Attention Rollout [10, 11] extracts an attention map from SegFormer’s encoder, and an Attention Consistency Loss compares it with a Gaussian-smoothed ground-truth mask, alongside the segmentation loss. Because the map is itself defined through a gradient, training requires second-order gradients. We call the resulting model CanopyFormer.

This paper makes four contributions: (1) an Attention Consistency Loss that supervises SegFormer-B0’s attention with the ground-truth forest mask during training, bringing attention supervision to the forestry domain; (2) an adaptation of Gradient-weighted Attention Rollout to SegFormer’s spatial-reduction attention (SRA), restricted to the only encoder stage where rollout is well defined, with every implementation choice specified; (3) AAMO, a mask-alignment metric reported alongside segmentation metrics and paired with a deletion-based faithfulness test; and (4) an empirical study on 5,108 images based on the DeepGlobe 2018 dataset [12], with baselines, loss-weight sweeps, mean squared error (MSE) versus Kullback–Leibler (KL) divergence, a three-seed ablation repeated on LoveDA, and overhead and overfitting checks.1

Forest-cover segmentation has been treated almost only as an accuracy problem: better encoders, better attention modules, and larger datasets, with U-Net [2] as the standard baseline. Related land-cover studies in Sri Lanka, for example, segment rubber plantations with VGG-16 + FCN-8 and U-Net [13] and paddy fields with Mask R-CNN [14], judged by accuracy alone. What the network attends to, and why, is rarely examined: in remote sensing, explanations are mostly post-hoc and anecdotal [7]. The closest work falls into two families.

Attention as Architecture

The first family uses attention to refine features and judges it only by segmentation accuracy. ForResANeXt [4] adds lightweight attention and attention-gated skip connections to residual blocks for satellite forest segmentation. Attention-Refined PP-LiteSeg [5] fuses channel, spatial, and pixel attention for cross-regional unmanned aerial vehicle (UAV) forest segmentation. An attention U-Net [6] adds attention gates for Sentinel-2 deforestation mapping. In all three, attention is neither supervised nor compared with any ground truth: it is an architectural convenience, not an explanation.

Attention as Explainability

The second family supervises attention as an interpretability output, but outside forest segmentation and without an attention-mask overlap metric. GAIN [15], the closest method, trains a CNN so that its Grad-CAM-style attention covers the whole object, optionally with pixel masks, for weakly supervised segmentation; it reports only mean intersection over union (mIoU) and does not address transformers. Porres et al. [16] align the attention of driving models with salient semantic maps, but evaluate driving, not segmentation.

Attention Extraction and Evaluation

Attention Rollout [11] multiplies attention matrices across layers to approximate token influence; its gradient-weighted variant [10], in the spirit of Grad-CAM [17], first weights the heads by the target gradient. Both assume square, token-consistent self-attention in every layer, which SegFormer’s Efficient Self-Attention violates (Section III-A). Attention maps are usually judged visually; numeric evaluation, when done, tests faithfulness by deleting the most relevant pixels [18] rather than measuring overlap with a ground truth. AAMO (Section IV) measures that overlap, and we also run a deletion test (§ 6-E).

Comparison and Research Gap

Table I compares our method with the closest work along five axes. No prior work combines (a) attention supervision during training, (b) forest segmentation, and (c) a quantitative alignment metric reported with segmentation metrics; ours does, and adds a faithfulness test. The same review confirms (a) and (c) field-wide: in remote sensing, only a few studies train explanations jointly with the model, and only 15 evaluate them quantitatively [7].

Method

The pipeline (Figure 1) adds a training-only attention-supervision path to SegFormer-B0, so inference is a standard SegFormer-B0 with no added cost. The MiT-B0 encoder and a multilayer perceptron (MLP) decoder map a red-green-blue (RGB) image XX to the predicted mask PP. In parallel, an adapted Gradient-weighted Attention Rollout turns the stage-4 attention into a map AA, and the Attention Consistency Loss LattL_{att}, added to the segmentation loss, pulls AA towards a Gaussian-smoothed ground-truth mask A∗A^{*}. In Figure 1, the bottom row runs only during training; thumbnails show a test tile.

Method overview showing the inference path and training-only path

Figure 1. Method overview: inference path (top) and training-only path (bottom).

Stage-4 Gradient-Weighted Attention Rollout

Rollout’s recursive matrix product needs square, token-consistent attention. SegFormer’s Efficient Self-Attention shrinks the keys and values by a spatial-reduction ratio (sr = 8, 4, 2 in stages 1–3), so those attention matrices are rectangular. Only stage 4 (sr = 1) has true self-attention: for a 256 × 256 input, n=64n=64 tokens on an 8 × 8 grid, with H=8H=8 heads in each of its two blocks b∈{1,2}b \in\{1,2\}. We verified these shapes empirically and therefore restricted rollout to stage 4; § 6-G estimates the signal this leaves out. Forward hooks capture each block’s softmax attention A(b)∈[0,1]H×n×n\mathbf{A}^{(b)} \in[0,1]^{H \times n \times n}, and the map is built in four steps.

(i) We explain the total predicted forest probability

s=∑usoftmax⁡(zu)forest,(1)s = \sum_{u} \operatorname{softmax}(z_u)_{\mathrm{forest}}, \tag*{(1)}

where uu ranges over the 64×6464 \times64 decoder grid, zuz_u are the two-class decoder logits at uu, and the subscript takes the forest-class probability, so one backward pass explains the whole forest prediction rather than one pixel.

(ii) With G(b)=∂s/∂A(b)\mathbf{G}^{(b)}=\partial s/\partial\mathbf{A}^{(b)}, each attention entry is weighted by its own gradient and the heads are averaged [10]:

Aˉ(b)=1H∑h=1H(Gh(b)⊙Ah(b))+∈Rn×n.(2)\bar{\mathbf{A}}^{(b)} = \frac{1}{H}\sum_{h=1}^{H}\left(\mathbf{G}^{(b)}_h \odot\mathbf{A}^{(b)}_h\right)^{+} \in\mathbb{R}^{n \times n}. \tag*{(2)}

where hh indexes the HH heads, ⊙\odot is the element-wise product, and (⋅)+(\cdot)^{+} zeroes negative entries. Unlike Grad-CAM, the gradient is not pooled: each query-key entry keeps its weight.

(iii) Each block adds the identity for its residual connection and is row-normalized, A~(b)=Db−1(Aˉ(b)+I)\widetilde{\mathbf{A}}^{(b)}=\mathbf{D}_b^{-1}(\bar{\mathbf{A}}^{(b)}+\mathbf{I}) with Db\mathbf{D}_b the diagonal matrix of row sums, and the two blocks are multiplied, R=A~(2)A~(1)R=\widetilde{\mathbf{A}}^{(2)}\widetilde{\mathbf{A}}^{(1)}.

(iv) SegFormer has no class token, so we average RR over all query rows, rj=1n∑iRijr_j=\frac{1}{n}\sum_i R_{ij}. The vector rr is clipped at zero, divided by its maximum, reshaped to 8×88\times8, and bilinearly upsampled to A∈[0,1]256×256A\in[0,1]^{256\times256}. Figure 2 shows steps (ii) to (iv).

Gradient-weighted attention rollout on SegFormer stage 4

Figure 2. Gradient-weighted attention rollout on SegFormer stage 4.

Loss Terms and Double Backpropagation

The soft target A∗=Gaussian⁡(Y,σ)A^{*}=\operatorname{Gaussian}(Y,\sigma) blurs the ground-truth mask Y∈{0,1}256×256Y\in\{0,1\}^{256\times256} with a separable kernel of radius 3σ3\sigma and divides by its maximum, so A∗∈[0,1]A^{*}\in[0,1]; σ=8\sigma=8 was tuned on the validation set. We implement two forms: a mean squared error averaged over pixels,

LattMSE=MSE⁡(A,A∗),(3)L_{att}^{\mathrm{MSE}}=\operatorname{MSE}(A,A^{*}), \tag*{(3)}
MethodAttention targetArchitectureDomain / taskExplanation methodEvaluation metric
ForResANeXt [4]None (architectural)CNN + attentionSatellite forest seg.NoneSegmentation metrics
PP-LiteSeg [5]None (architectural)CNN + attentionUAV forest seg.NoneSegmentation metrics
Attention U-Net [6]None (architectural)CNN + attention gatesSentinel-2 deforestationNoneSegmentation metrics
Mahakalanda et al. [13]NoneCNN (FCN-8, U-Net)Sentinel-2 rubberNoneAccuracy, IoU, Dice
Meedeniya et al. [14]NoneMask R-CNNSentinel-2 paddyNoneAverage precision
Attention Rollout [11]None (post-hoc)TransformerNatural languageRollout / flowAgreement with ablation
Chefer et al. [10]None (post-hoc)ViTImage classificationRelevance propagationPerturbation tests
GAIN [15]Self-guidance, masksCNNWeakly supervised seg.Grad-CAM-styleSegmentation mIoU
Porres et al. [16]Salient semantic mapsCNN + transformerDriving (CARLA)Attention weightsDriving benchmarks
OursSmoothed forest maskSegFormer-B0 (SRA)Aerial forest seg.Stage-4 rolloutDice, AAMO, deletion

Table I. Comparison with the closest land-cover, attention-supervision, and explainability work.

where AA is the rollout map and A∗A^{*} the soft target, and a KL divergence that treats both as distributions over pixels,

LattKL=KL⁡(A∥A∗).(4)L_{att}^{\mathrm{KL}} = \operatorname{KL}(A \mathbin\Vert A^{*}). \tag*{(4)}

MSE is clearly better (§ 6-C), so LattL_{att} denotes LattMSEL_{att}^{\mathrm{MSE}} unless stated otherwise.

Most errors occur near canopy edges, so, following edge-focused losses [19], the Boundary Refinement Module adds a Dice term on the boundaries of prediction and ground truth:

Lboundary=1−2∣∂P∩∂Y∣∣∂P∣+∣∂Y∣,(5)L_{boundary} = 1 - \frac{2\lvert\partial P \cap\partial Y\rvert}{\lvert\partial P\rvert+ \lvert\partial Y\rvert}, \tag*{(5)}

where PP is the predicted forest-probability map, YY the ground-truth mask, ∂(⋅)\partial(\cdot) the morphological gradient (3×33 \times3 kernel), which keeps only boundary pixels, ∩\cap the pixel-wise product, and ∣⋅∣\lvert\cdot\rvert the sum over pixels; tables abbreviate the loss as LbndL_{bnd}. It is added on top of LattL_{att}, not instead of it, with weight λ3\lambda_3 chosen on the validation set (§ 6-B).

With a Dice loss LdiceL_{dice} and binary cross-entropy LbceL_{bce} on PP and YY, the full objective is

L=Ldice+λ1Lbce+λ2Latt+λ3Lboundary,(6)L = L_{dice} + \lambda_1 L_{bce} + \lambda_2 L_{att} + \lambda_3 L_{boundary}, \tag*{(6)}

where λ1\lambda_1, λ2\lambda_2 and λ3\lambda_3 weight the terms, with λ1=1\lambda_1 = 1. Because AA is itself built from a gradient, backpropagating LattL_{att} needs a second derivative. We compute G(b)G^{(b)} with create_graph=True, so AA stays in the autograd graph and one backward() reaches every parameter. This makes a training step 2.6–2.8×\times slower (§ 6-F).

Average Attention-Mask Overlap

AAMO makes attention-mask alignment reportable and comparable. Given an attention map min-max rescaled to A∈[0,1]256×256A \in[0,1]^{256 \times256} and the mask YY, we first threshold the map at τ=0.5\tau= 0.5,

Athr=1[A≥τ],(7)A_{\mathrm{thr}} = \mathbb{1}[A \ge\tau], \tag*{(7)}

where 1[⋅]\mathbb{1}[\cdot] is 1 at pixels where the condition holds and 0 elsewhere, and then measure how much of the mask YY the thresholded map covers:

AAMO=∣Athr∩Y∣∣Y∣.(8)\mathrm{AAMO} = \frac{\lvert A_{\mathrm{thr}} \cap Y\rvert}{\lvert Y\rvert}. \tag*{(8)}

where ∩\cap keeps the pixels set in both maps and ∣⋅∣\lvert\cdot\rvert counts pixels. AAMO is the recall of the forest mask under thresholded attention: 1.0 means full coverage and 0.0 no overlap. Images with an empty mask contribute 0, and we report the mean over all images of a split.

As a recall, AAMO does not penalize attention that spills onto nonforest areas. In practice, 81% of the thresholded CanopyFormer map lay on forest, against 61% for a map marking every pixel and under 60% for the vanilla map, and the ranking held for τ\tau from 0.3 to 0.7. More importantly, it measures plausibility, not faithfulness: a map can overlap the mask while the prediction relies on other evidence [9]. Since LattL_{att} directly optimizes overlap with A∗A^{*}, part of the AAMO gain is expected by construction. We therefore pair AAMO with a deletion test of faithfulness [18] (§ 6-E).

Experimental Setup

We used 5,108 RGB aerial images (256×256256 \times256) with binary forest/nonforest masks, based on the DeepGlobe 2018 challenge [12]. They were split 70:15:15 (3576/766/766) with seed 42, so all models shared one test set; in the multi-seed runs, the seed also redrew the split (§ 6-D). An audit script confirmed that all files were readable and all masks binary. Because the data are forest-majority (mean forest ratio 0.6117±0.33060.6117 \pm0.3306 per mask), we used Dice, intersection over union (IoU), and F1 score rather than pixel accuracy.

U-Net [2] and a vanilla SegFormer-B0 (no attention loss) isolated the effect of supervision, and DeepLab V3+ [20] with a MobileNetV3 [21] backbone added a second CNN reference. SegFormer-B2 [3] and Swin-T with UPerNet [22, 23] served as larger transformer baselines, trained from ImageNet-pretrained encoders with the same split, epochs, optimizer, and checkpoint rule, at batch size 16 on a T4 graphics processing unit (GPU) (best epochs 8 and 12).

Besides Dice, IoU, and F1, we report AAMO (alignment), the deletion score drop (faithfulness, § 6-E), and parameters, GMACs (billions of multiply-accumulates), time, and peak memory (efficiency, § 6-F).

SegFormer-B0 variants were trained for 20 epochs with AdamW (learning rate 6×10−56 \times10^{-5}), at batch size 16 for the vanilla model and 1 for the attention and boundary variants, whose rollout was computed per image. We used λ2=1.0\lambda_2 = 1.0, chosen by the validation sweep (§ 6-B), and report each variant’s best-validation checkpoint, since validation Dice peaked early (§ 6-G).

Results

Main Comparison

Table II reports all models on the shared seed-42 test set. The Attention Consistency Loss raised AAMO about 22-fold while Dice stayed nearly flat. Figure 3 plots test Dice against test AAMO for every SegFormer-B0 variant at seed 42; the dashed path follows λ2\lambda_2 from the vanilla model (λ2=0\lambda_2 = 0) to CanopyFormer. The vanilla SegFormer-B0 already beat U-Net with under an eighth of its parameters. SegFormer-B2 and Swin-T + UPerNet were slightly more accurate, but 7 and 16 times larger and several times slower on a T4 GPU. SegFormer-B0’s small size is what keeps per-image rollout and double backpropagation affordable. Against SegFormer-B2, CanopyFormer gave up about two Dice points for a seventh of the parameters and an attention map that follows the canopy.

ModelDiceIoUF1AAMOParams
U-Net (CNN)0.86150.75680.8615n/a31.0 M
DeepLabV3+ (MNetV3)0.87160.77240.8716n/a11.0 M
SegFormer-B20.88090.78720.8809n/a27.3 M
Swin-T + UPerNet0.87930.78470.8793n/a58.9 M
SegFormer-B00.87430.77660.87430.03343.7 M
+ LattL_{att} (MSE), CanopyFormer0.85770.75080.85770.74763.7 M
+ LattL_{att} (KL)0.74620.59510.74620.34123.7 M
+ Latt+LbndL_{att} + L_{bnd} (λ3=0.5\lambda_3=0.5)0.86110.75600.86110.68053.7 M

Table II. Test results (seed 42, shared 766-image test set). The KL row changes only the form of LattL_{att}.

Figure 3. Alignment against accuracy for the SegFormer-B0 variants.

Loss-Weight Selection

Table III lists all weights tried. Raising λ2\lambda_2 lifted AAMO while Dice barely moved, so we picked λ2=1.0\lambda_2 = 1.0, the highest validation AAMO; validation and test agreed, so the test split played no part. With λ2\lambda_2 fixed, we ranked λ3\lambda_3 by validation Dice, then IoU. Seed 42 alone favored 0.2, which lost much alignment, but the three-seed mean favored 0.5, a weak preference of under one standard deviation. Weights of 0.2 or more also moved the best checkpoint much earlier.

WeightValidation DiceValidation AAMOTest Dice (3 seeds)Test DiceTest AAMOBest epoch
λ2=0.1\lambda_2 = 0.10.86640.5354–0.85230.54814
λ2=0.3\lambda_2 = 0.30.86950.5801–0.86900.57523
λ2=0.5\lambda_2 = 0.50.86610.6014–0.86440.60284
λ2=1.0\lambda_2 = 1.00.86260.7519–0.85770.747611
λ3=0.1\lambda_3 = 0.10.8601–0.8475 ± 0.01230.85580.777511
λ3=0.2\lambda_3 = 0.20.8717–0.8512 ± 0.02810.86690.62184
λ3=0.5\lambda_3 = 0.50.8685–0.8582 ± 0.01080.86110.68054

Table III. Loss-weight selection (seed 42 unless noted); selected weights in bold.

Choice of Attention Loss

Replacing MSE with KL hurt every metric in Table II: Dice fell by 11 points and AAMO by more than half. The gap dwarfed the seed-to-seed spread of the MSE model and already appeared on validation, so KL is simply a weaker objective, not one that generalizes worse. A likely reason is that KL penalizes the ratio A/A∗A/A^*, which puts more gradient on low-target pixels where A∗A^* is nonzero, whereas MSE penalizes ∣A−A∗∣|A-A^*| directly.

Multi-Seed Ablation and Cross-Dataset Check

Table IV summarizes seeds 42, 43 and 44. On DeepGlobe, the seed also redrew the data split. The vanilla and attention models were stable across seeds. The boundary model was not: at λ3=0.2\lambda_3 = 0.2, seed 43 fell about 4 Dice points below the other two, while λ3=0.5\lambda_3 = 0.5, the setting in Table IV, varied less. AAMO was noisier, and the two supervised models swapped order at seed 43.

ConfigDiceIoUAAMO
DeepGlobe-based (seed also redraws the split)
Vanilla0.8723 ± 0.00240.7735 ± 0.00380.0435 ± 0.0167
+ LattL_{att} (MSE)0.8564 ± 0.00260.7488 ± 0.00390.7028 ± 0.0392
+ LattL_{att} + LbndL_{bnd}0.8505 ± 0.01390.7399 ± 0.02080.6881 ± 0.0719
LoveDA (one fixed split)
Vanilla0.7094 ± 0.00770.5497 ± 0.00920.0217 ± 0.0019
+ LattL_{att} (MSE)0.6955 ± 0.00120.5332 ± 0.00140.6209 ± 0.0520
+ LattL_{att} + LbndL_{bnd}0.6706 ± 0.02200.5048 ± 0.02510.5924 ± 0.0134

Table IV. MEAN ± STANDARD DEVIATION OVER THREE SEEDS.

We also repeated the three configurations, with unchanged code and settings, on the LoveDA land-cover dataset [24], with forest as the positive class, splits of the same sizes, and the LoveDA validation tiles as the test set. Accuracy was lower, but the pattern held: LattL_{att} raised AAMO about 28-fold in every seed at a small Dice cost, while LbndL_{bnd} lowered both Dice and AAMO. Reruns of two seeds on other GPUs shifted test Dice by up to 5.5 points without changing either conclusion.

Faithfulness: Deletion Test

We ran a deletion test [18] on the 766 test images with the seed-42 vanilla and attention models. Each image was split into the 8×88 \times8 grid of 32 ×\times 32 patches that matches the stage-4 tokens; we replaced the top-k%k\% of patches (k=10,25,50k = 10, 25, 50, i.e., 6, 16 and 32 of the 64 patches) with the mean color or a blurred copy (Gaussian, σ=16\sigma= 16 pixels) and recorded the relative drop of ss. Patches were ranked by mean attention, at random, or by ground-truth forest fraction (forest-first). Forest-first is the key control: since LattL_{att} pulls attention onto forest, attention-ranked deletion must beat it to show that the map ranks patches by reliance, not by class.

Figure 4 plots the mean relative drop of ss (±1 standard error), one row per model and one column per replacement. The result is clearly negative. For the supervised model, deleting the most-attended patches was the weakest order at every budget and with both replacements: removing the top 25% lowered ss by only 12.1%, against 33.0% for random patches, and forest-first sat in between. For the vanilla model, attention stayed close to random and well below forest-first. Neither map ranks patches by how much the prediction depends on them: the 22-fold AAMO gain is a gain in alignment, not faithfulness. One untested explanation is redundancy: the supervised map covers canopy interiors, where neighboring patches support the same prediction. The pipeline reproduced Table II’s AAMO exactly.

Figure 4. Deletion test: drop of the forest score ss for each deletion order.

Computational Overhead

We also timed one batch-1 training step of each model on a laptop central processing unit (CPU; 12th-generation Intel Core, 4 threads) and a T4 GPU (Table V). The cost lay in training: a step took 2.6–2.8× as long for only a third more compute, because the second backward pass consists of many small operations. An explanation map cost one extra backward pass; the boundary module added 4% step time.

QuantityCPU (laptop)GPU
Vanilla+ LattL_{att}RatioVanilla+ LattL_{att}Ratio
Inference (ms/image)72721.009.0–11.89.7≈1
Training step (ms)40111082.834902.6
Peak memory (MB)203b^{b}259b^{b}1.271491861.25
Explanation map (ms)209209–3939–
Time per epoch (s)a^{a}443868.8
Step compute (GMACs)c^{c}10.714.21.33–––

Table V. COMPUTATIONAL OVERHEAD OF ATTENTION SUPERVISION.

Diagnostics and Qualitative Results

Every run overfitted: validation loss turned upward after an early minimum while training metrics kept improving.

GPU batch-1 rows: T4. a^{a}Full-scale runs, 3-seed mean (vanilla batch 16, attention batch 1). b^{b}Group over loaded model. c^{c}Device-independent.

The train/validation Dice gap widened most for the vanilla model, so LattL_{att} and LboundaryL_{boundary} act as mild regularizers. In a single-seed grid, weight decay helped only the vanilla model; the attention model did best with a cosine schedule. To check what the stage-4 restriction discards, we averaged each stage’s raw attention onto the 8 × 8 grid and correlated it with the downsampled masks. Stages 1–3 correlated only weakly (r≤0.19r \le0.19) and stage 4 strongly (r=0.52r = 0.52), so the restriction mainly removes mask-irrelevant signal.

Figure 5 shows a test tile with 30–70% forest, its mask (white line), both attention maps scaled to [0, 1], and CanopyFormer’s prediction, all from the seed-43 models. Per-image AAMO rises from 0.03 to 0.98. CanopyFormer’s map covers the canopy and falls off at the forest boundary. The vanilla attention collects in a corner hot spot rather than on roads or shadows, a pattern that persisted at full scale and so is unlikely to come from undertraining.

Discussion

The large AAMO gain at a small Dice cost, and the steady AAMO rise over a nearly flat Dice range in the λ2\lambda_2 sweep, suggest a tunable trade-off between alignment and accuracy. By the deletion test, the alignment gained by LattL_{att} is not faithfulness, so AAMO does not show that the model’s evidence.

Adding LboundaryL_{boundary} did not raise Dice reliably, lowered AAMO, and moved the best checkpoint much earlier. A possible cause is gradient competition in the shared encoder: sharp edge features favored by LboundaryL_{boundary} may conflict with the canopy-focused target of LattL_{att}.

The deployed model is a plain SegFormer-B0, small enough for a forest-change web tool, on-board drone use, or flagging tiles where explanation and mask disagree. Before real deforestation decisions, it needs validation on the target region and sensor (e.g., Sri Lankan forests) and human review.

Several limitations remain. The transformer baselines were single-seed, and DeepLabV3+ varied only its initialization. The boundary model’s variance came mainly from seed 43, whose best checkpoint arrived much later and whose test Dice was lower, although the same split trained normally without LboundaryL_{boundary}. AAMO is partly optimized by construction, and the single-seed, patch-level deletion test could rank the maps differently under another measure.

Conclusion and Future Work

We supervised SegFormer-B0’s attention with the forest mask through an Attention Consistency Loss, adapted Gradient-weighted Attention Rollout to spatial-reduction attention, and introduced AAMO. The loss raised AAMO about 22-fold at a small Dice cost, also on LoveDA; it slows training but not inference. A deletion test showed this to be a gain in alignment, not faithfulness. The Boundary Refinement Module gave no consistent Dice gain and reduced AAMO, and MSE beat KL as the attention loss. Future work will train for faithfulness, decouple the boundary head, add seeds and baselines, and validate on Sri Lankan multispectral imagery.

References

  1. [1]D. A. Meedeniya, J. A. A. M. Jayanetti, M. D. N. Dilini, M. H. Wickramapala, and J. H. Madushanka, “Land-use classification with integrated data,” in Machine Vision Inspection Systems, Vol. 1: Image Processing, Concepts, Methodologies, and Applications, M. Malardvel, S. R. Nayak, S. N. Panda, P. K. Pattnaik, and N. Muangnak, Eds. Hoboken, NJ, USA: Wiley-Scrivener, 2020, ch. 1, pp. 1–36.DOI
  2. [2]O. Ronneberger, P. Fischer, and T. Brox, “U-Net: Convolutional networks for biomedical image segmentation,” in Medical Image Computing and Computer-Assisted Intervention (MICCAI), Munich, Germany, 2015, pp. 234–241.arxiv.org/abs/1505.04597
  3. [3]E. Xie, W. Wang, Z. Yu, A. Anandkumar, J. M. Alvarez, and P. Luo, “SegFormer: Simple and efficient design for semantic segmentation with transformers,” in Advances in Neural Information Processing Systems (NeurIPS), vol. 34. Red Hook, NY, USA: Curran Associates, 2021, pp. 12 077–12 090.
  4. [4]Q. Guo, L. Li, and L. Han, “ForResANeXt: Forest/non-forest segmentation with aggregated residual attention network in satellite imagery,” International Journal of Applied Earth Observation and Geoinformation, vol. 146, 2026, Art. no. 105105.
  5. [5]X. Ma, S. Zhang, K. Li, X. Wang, H. Lin, and Z. Qiang, “Enhancing cross-regional generalization in UAV forest segmentation across plantation and natural forests with attention-refined PP-LiteSeg networks,” Remote Sensing, vol. 18, no. 3, 2026, Art. no. 523.
  6. [6]D. John and C. Zhang, “An attention-based U-Net for detecting deforestation within satellite sensor imagery,” International Journal of Applied Earth Observation and Geoinformation, vol. 107, 2022, Art. no. 102685.
  7. [7]A. Höhl et al., “Opening the black box: A systematic review on explainable artificial intelligence in remote sensing,” IEEE Geoscience and Remote Sensing Magazine, vol. 12, no. 4, pp. 261–304, 2024.
  8. [8]A. Jacovi and Y. Goldberg, “Towards faithfully interpretable NLP systems: How should we define and evaluate faithfulness?” in Annual Meeting of the Association for Computational Linguistics (ACL), Stroudsburg, PA, USA: ACL, 2020, pp. 4198–4205.arxiv.org/abs/2004.03685
  9. [9]S. Jain and B. C. Wallace, “Attention is not explanation,” in Conference of the North American Chapter of the Association for Computational Linguistics (NAACL-HLT), Minneapolis, MN, USA, 2019, pp. 3543–3556.
  10. [10]H. Chefer, S. Gur, and L. Wolf, “Transformer interpretability beyond attention visualization,” in IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Nashville, TN, USA, 2021, pp. 782–791.arxiv.org/abs/2012.09838
  11. [11]S. Abnar and W. Zuidema, “Quantifying attention flow in transformers,” in Annual Meeting of the Association for Computational Linguistics (ACL). Stroudsburg, PA, USA: ACL, 2020, pp. 4190–4197.arxiv.org/abs/2005.00928
  12. [12]I. Demir et al., “DeepGlobe 2018: A challenge to parse the earth through satellite images,” in IEEE Conference on Computer Vision and Pattern Recognition (CVPR) Workshops, Salt Lake City, UT, USA, 2018, pp. 172–181.DOI
  13. [13]I. Mahakalandа, P. Demotte, I. Perera, D. Meedeniya, W. Wijesuriya, and L. Rodrigo, “Deep learning-based prediction for stand age and land utilization of rubber plantation,” in Application of Machine Learning in Agriculture, M. A. Khan, R. Khan, and M. A. Ansari, Eds. London, U.K.: Elsevier Academic Press, 2022, ch. 7, pp. 131–156.
  14. [14]D. A. Meedeniya et al., “Prediction of paddy cultivation using deep learning on land cover variation for sustainable agriculture,” in Deep Learning for Sustainable Agriculture, R. C. Poonia, V. Singh, and S. R. Nayak, Eds. London, U.K.: Elsevier Academic Press, 2022, ch. 13, pp. 325–355.DOI
  15. [15]K. Li, Z. Wu, K.-C. Peng, J. Ernst, and Y. Fu, “Tell me where to look: Guided attention inference network,” in IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Salt Lake City, UT, USA, 2018, pp. 9215–9223.arxiv.org/abs/1802.10171
  16. [16]D. Porres, Y. Xiao, G. Villalonga, A. Levy, and A. M. López, “Guiding attention in end-to-end driving models,” in IEEE Intelligent Vehicles Symposium (IV), Jeju Island, Republic of Korea, 2024, pp. 2353–2360.DOI
  17. [17]R. R. Selvaraju, M. Cogswell, A. Das, R. Vedantam, D. Parikh, and D. Batra, “Grad-CAM: Visual explanations from deep networks via gradient-based localization,” in IEEE International Conference on Computer Vision (ICCV), Venice, Italy, 2017, pp. 618–626.
  18. [18]W. Samek, A. Binder, G. Montavon, S. Lapuschkin, and K.-R. Müller, “Evaluating the visualization of what a deep neural network has learned,” IEEE Transactions on Neural Networks and Learning Systems, vol. 28, no. 11, pp. 2660–2673, 2017.DOI
  19. [19]H. Kervadec, J. Bouchtiba, C. Desrosiers, E. Granger, J. Dolz, and I. Ben Ayed, “Boundary loss for highly unbalanced segmentation,” in Medical Imaging with Deep Learning (MIDL), ser. PMLR, vol. 102, London, U.K., 2019, pp. 285–296.
  20. [20]L.-C. Chen, Y. Zhu, G. Papandreou, F. Schroff, and H. Adam, “Encoder-decoder with atrous separable convolution for semantic image segmentation,” in European Conference on Computer Vision (ECCV), Munich, Germany, 2018, pp. 833–851.arxiv.org/abs/1802.02611
  21. [21]A. Howard et al., “Searching for MobileNetV3,” in IEEE International Conference on Computer Vision (ICCV), Seoul, Republic of Korea, 2019, pp. 1314–1324.arxiv.org/abs/1905.02244
  22. [22]Z. Liu et al., “Swin transformer: Hierarchical vision transformer using shifted windows,” in IEEE/CVF International Conference on Computer Vision (ICCV), Montreal, QC, Canada, 2021, pp. 9992–10 002.arxiv.org/abs/2103.14030
  23. [23]T. Xiao, Y. Liu, B. Zhou, Y. Jiang, and J. Sun, “Unified perceptual parsing for scene understanding,” in European Conference on Computer Vision (ECCV), Munich, Germany, 2018, pp. 432–448.arxiv.org/abs/1807.10221
  24. [24]J. Wang, Z. Zheng, A. Ma, X. Lu, and Y. Zhong, “LoveDA: A remote sensing land-cover dataset for domain adaptive semantic segmentation,” in Neural Information Processing Systems Track on Datasets and Benchmarks, vol. 1, 2021.arxiv.org/abs/2110.08733

Paper details

vlnc:W_tdxpkr6d
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 10

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents