Paper · 2023-08-31 · cs.CV
Beyond Self-Attention: Deformable Large Kernel Attention for Medical Image Segmentation
D-LKA Net is a hybrid transformer-CNN for medical segmentation. Its attention stacks depthwise convolutions with large effective kernels and deformable sampling, and needs no softmax. A 3D variant mixes neighbouring slices. Author-reported: 84.27 mean DSC on Synapse 2D, 87.49 on Synapse 3D, with 42.35M parameters in 3D.
Semantic segmentationDeformable convolutionCNN-Transformer hybridHierarchical vision transformersmedical-image-segmentationattentiondeformable-convolutionvision-transformer
arXivPDFCodeMarkdown18 min read
AI-compiled by claude-haiku-5-5 on 2026-11-09, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Segmentation means labelling every pixel of an image, here an organ, a skin lesion or a pancreas in a medical scan. Transformer networks see the whole image at once, which helps, but their cost grows quickly with image size. Many medical methods also treat a 3D scan as a stack of 2D slices, so they lose information between neighbouring slices.
The paper builds a block that gets a wide view cheaply. It uses a few large, cheap convolutions to mix information over a big area, and lets the sampling pattern of those convolutions bend to follow the shape of the structure. A 2D version works on single slices; a 3D version lets neighbouring slices inform each other. The authors place these blocks in a hierarchical network. On the datasets they test, they report higher average overlap scores (Dice) than the networks they compare against.
TL;DR
D-LKA Net is a hybrid transformer-CNN for medical segmentation. Its attention replaces self-attention with stacked large depthwise convolutions and deformable sampling. The 2D version uses a MaxViT encoder; the 3D version is meant to share information across slices. Author-reported: average DSC 84.27 on Synapse 2D, 87.49 on Synapse 3D and 81.22 on the NIH Pancreas set, each the highest average in its table. The released code's defaults differ from the paper in several places (see Paper vs code).
Problem
- Self-attention cost grows with the square of the token count, which limits network depth and input resolution [abstract].
- Most methods process 3D volumes slice by slice and so miss information between slices §1.
- CNNs capture local texture but miss global context; ViTs capture global context but model local detail less well §1.
- Lesions and organs deform in shape, so a learned operator should handle deformation while staying cheap enough for 3D volumes §1.
The paper states no assumptions about data beyond the datasets in §3.2.
Method
Overview. The core block is D-LKA attention. It starts from Large Kernel Attention (LKA) §2.1 and makes its convolutions deformable §2.2. Two networks use it: a 2D network with a MaxViT encoder and D-LKA decoder §2.3, and a 3D encoder-decoder §2.4.
Step 1. LKA as large-kernel, low-cost attention §2.1. A K×K kernel is built from a depthwise convolution with kernel (2d−1)×(2d−1), a depthwise dilated convolution with kernel ⌈K/d⌉×⌈K/d⌉ at dilation d, and a 1×1 convolution eq. 1 eq. 2. For C channels the parameter count is P(K,d) = C(⌈K/d⌉² + (2d−1)² + 3 + C) eq. 3. FLOPs are F(K,d) = P·H·W eq. 4. The 3D analogues are eq. 6 and eq. 7. The paper says a dilation of about 3.37 minimises parameters for K = 21 §2.1 (see Pitfalls for the sign of the derivative in eq. 5).
Step 2. Deformable depthwise convolutions §2.2. Each deformable convolution learns offsets from the feature map with an extra convolution. The offset convolution follows the kernel size and dilation of its layer. Off-grid samples use bilinear interpolation. The 2D D-LKA attention is:
- F′ = GELU(Conv(F)) eq. 8;
- Attention = Conv1×1(DDW-D-Conv(DDW-Conv(F′))) eq. 8, where DDW is a deformable depthwise convolution and DDW-D its dilated form;
- Output = Conv1×1(Attention ⊗ F′) + F eq. 8, with ⊗ the element-wise product.
No sigmoid or softmax normalises the attention map. The paper argues that such normalisers suppress high-frequency information §2.2.
# Deformable LKA attention, 2D [eq. 8]
# [code: 2D/deformable_LKA/deformable_LKA.py#L93-L94]
# Input: features (B, C, H, W); output: (B, C, H, W)
def deformable_lka_attention(features):
# F' = GELU(Conv1x1(F)) [eq. 8]
gated_input = gelu(conv1x1(features)) # (B, C, H, W)
# Deformable depthwise 5x5, then 7x7 with dilation 3 [§2.2]
spatial = deform_dw_5x5(gated_input) # (B, C, H, W)
spatial = deform_dw_7x7_dilated(spatial) # (B, C, H, W)
# Attention map: 1x1 conv, no sigmoid or softmax [eq. 8]
attention = conv1x1(spatial) # (B, C, H, W)
# Element-wise gating, 1x1 projection, residual [eq. 8]
mixed = conv1x1(attention * gated_input) # (B, C, H, W)
return mixed + featuresStep 3. Deformable LKA in 2D §2.2 §2.3. Both convolutions in the attention are deformable. The 2D block is eq. 9 to eq. 11: LayerNorm, the deformable LKA attention with a residual, then a Conv1×1 → depthwise conv → GELU → Conv1×1 MLP with a residual. The kernel size of the depthwise conv in the MLP is not stated.
# 2D D-LKA block [eq. 9-11]
# Input: x_in (B, C, H, W); output: (B, C, H, W)
def d_lka_block_2d(x_in):
# Attention branch with residual [eq. 9]
x_1 = deformable_lka_attention(layer_norm(x_in)) + x_in
# MLP branch with residual [eq. 10]
x_out = mlp_2d(layer_norm(x_1)) + x_1
return x_out
def mlp_2d(x):
# Conv1x1, depthwise conv, GELU, Conv1x1 [eq. 11]
x = conv1x1(x)
x = depthwise_conv(x) # kernel size not stated
x = gelu(x)
return conv1x1(x)Step 4. 2D network §2.3 fig. 1 fig. 2. A convolutional stem reduces the input to H/4 × W/4 × C. Four MaxViT stages follow, each with downsampling §2.3. The decoder has four stages; each has two D-LKA blocks, then patch-expanding layers that upsample and reduce channels. A final linear layer produces the output §2.3.
Step 5. Deformable LKA in 3D §2.2 §2.4. Offset generation in 3D would multiply the channel count (the paper says output channels grow to 3·k×k×k), so the 3D version uses one deformable convolution after the depthwise convolutions instead of two §2.2. The 3D block is eq. 12 and eq. 13: LayerNorm, the 3D attention with a residual, then Conv1×1 applied to a feed-forward network Conv3 (two convolutions and activations, per the text §2.4) with a residual.
# 3D D-LKA block [eq. 12-13]
# Input: x_in (B, C, H, W, D); output: (B, C, H, W, D)
def d_lka_block_3d(x_in):
# LayerNorm, 3D deformable LKA attention, residual [eq. 12]
x_1 = d_lka_attention_3d(layer_norm(x_in)) + x_in
# Feed-forward Conv3 (two convs, activations), then Conv1x1 [eq. 13]
x_out = conv1x1x1(feed_forward_3d(x_1)) + x_1
return x_outStep 6. 3D network §2.4 fig. 1. A patch embedding maps H×W×D to H/4 × W/4 × D/2 §2.4. The encoder has three stages of three D-LKA blocks; each stage ends with a downsampling step that halves resolution and doubles channels. The bottleneck has two D-LKA blocks. The decoder mirrors the encoder with transposed convolutions, three blocks per stage §2.4. Skip connections add features from other stages; an extra convolutional skip links the input to the output §2.4. The output is a 3×3×3 convolution followed by a 1×1×1 convolution §2.4. Ablation shows the number of skip connections matters tab. 6.
Step 7. Loss §3.1 eq. 14. For the 2D method, the paper trains on 0.6 × Dice + 0.4 × cross-entropy eq. 14. The text attaches this to the 2D setup only; the 3D loss is not stated.
# Training loss, 2D [eq. 14]
# [code: 2D/trainer_MaxViT_deform_LKA.py#L137-L139]
# Input: logits (B, K, H, W), labels (B, H, W); output: scalar
def training_loss_2d(logits, labels):
# Cross-entropy term [eq. 14]
loss_ce = cross_entropy(logits, labels)
# Soft Dice term over the softmax [eq. 14]
loss_dice = dice_loss(softmax(logits), labels)
# Weighted sum as stated in eq. 14
return 0.6 * loss_dice + 0.4 * loss_ceHyperparameters
Values are as stated in the paper unless marked "code". "not stated" means the paper is silent. Code values are from the release at code_commit; they are not the paper's claim.
| Name | Value | Where | Notes |
|---|---|---|---|
| 2D: optimiser | SGD, momentum 0.9 | §3.1 | code matches trainer_MaxViT_deform_LKA.py |
| 2D: base learning rate | 0.05 | §3.1 | code default 0.05 train_MaxViT_deform_LKA.py; scaled by batch/24 for other batch sizes that are multiples of 5 train_MaxViT_deform_LKA.py |
| 2D: weight decay | 0.0001 | §3.1 | code matches trainer_MaxViT_deform_LKA.py |
| 2D: batch size | 20 | §3.1 | code default 24 train_MaxViT_deform_LKA.py |
| 2D: epochs | 400 | §3.1 | code default 400 train_MaxViT_deform_LKA.py |
| 2D: LR schedule | not stated | — | code: polynomial decay with power 0.9 per iteration trainer_MaxViT_deform_LKA.py |
| 2D: loss | 0.6 Dice + 0.4 CE | eq. 14 §3.1 | code uses 0.4 CE + 0.6 Dice trainer_MaxViT_deform_LKA.py |
| 2D: input size | not stated | — | code default 224 train_MaxViT_deform_LKA.py; timing uses 224×224 app. A |
| 2D: augmentation | same as TransUNet | §3.1 | the augmentations are not described in the paper |
| 2D: seed | not stated | — | code default 1234 train_MaxViT_deform_LKA.py |
| 3D: optimiser | SGD | §3.1 | code: SGD, Nesterov, momentum 0.99 d_lka_former_trainer_synapse.py — momentum not stated in paper |
| 3D: base learning rate | 0.01 | §3.1 | code initial_lr 1e-2 d_lka_former_trainer_synapse.py |
| 3D: weight decay | 3e-5 | §3.1 | code 3e-5 Trainer_synapse.py |
| 3D: batch size | 2 | §3.1 | code reads batch size from a plans file not in the repo Trainer_synapse.py |
| 3D: epochs | 1000 | §3.1 | code 1000 d_lka_former_trainer_synapse.py |
| 3D: patches per epoch | 250 | §3.1 | code 250 training, 50 validation batches network_trainer_synapse.py |
| 3D: patch size | 128 × 128 × 64 | §3.1 | code crop_size [64, 128, 128] d_lka_former_trainer_synapse.py; training patch size comes from the plans file Trainer_synapse.py |
| 3D: LR schedule | not stated | — | code: polynomial decay with power 0.9 per epoch d_lka_former_trainer_synapse.py |
| 3D: loss | not stated | — | code: Dice + CE, both weights 1 Trainer_synapse.py dice_loss.py |
| 3D: deep supervision | not stated | — | code: outputs weighted by 1/2^i, normalised d_lka_former_trainer_synapse.py |
| 3D: encoder depths | three stages of three blocks; bottleneck two | §2.4 | the release defaults to depths 3 run_training_synapse.sh |
| 3D: skip connections | 4 is the best setting | tab. 6 | code default 4 run_training.py |
| 3D: augmentation | same as nnFormer and UNETR++ | §3.1 | not described in the paper |
| Hardware | single RTX 3090 | §3.1 | — |
| Pancreas: training | not stated | §3.2 | see Paper vs code for the released script |
| Skin: training | not stated | §3.2 | see Paper vs code for the released skin scripts |
Input and output details:
- Synapse: 30 cases, 3779 axial CT images in total; 85–198 slices per volume, 512×512 each; voxel spacing 0.54–0.54 × 0.98–0.98 × 2.5–5.0 mm §3.2. The split follows TransUNet and UNETR++ §3.2.
- ISIC 2017: 2000 train, 150 validation, 600 test §3.2. ISIC 2018: the division follows a scheme "described in previous literature", which the card does not reproduce §3.2. PH2: 200 images (160 nevi, 40 melanomas); split not stated §3.2.
- NIH Pancreas: 82 volumes; 62 for training and the rest for testing, so 20 by arithmetic §3.2.
Results
Author-reported. Setup: single RTX 3090 §3.1; each dataset as above §3.2. The paper marks best and second-best with colour, which is not reproduced here.
Synapse, 2D tab. 1. Params in millions, FLOPs in billions, DSC and HD95 as averages over organs.
| Method | Params (M) | FLOPs (G) | Spl | RKid | LKid | Gal | Liv | Sto | Aor | Pan | DSC ↑ | HD95 ↓ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| TransUNet | 96.07 | 88.91 | 85.08 | 77.02 | 81.87 | 63.16 | 94.08 | 75.62 | 87.23 | 55.86 | 77.49 | 31.69 |
| Swin-UNet | 27.17 | 6.16 | 90.66 | 79.61 | 83.28 | 66.53 | 94.29 | 76.60 | 85.47 | 56.58 | 79.13 | 21.55 |
| LeViT-UNet-384 | 52.17 | 25.55 | 88.86 | 80.25 | 84.61 | 62.23 | 93.11 | 72.76 | 87.33 | 59.07 | 78.53 | 16.84 |
| MISSFormer | 42.46 | 9.89 | 91.92 | 82.00 | 85.21 | 68.65 | 94.41 | 80.81 | 86.99 | 65.67 | 81.96 | 18.20 |
| ScaleFormer | 111.6 | 48.93 | 89.40 | 83.31 | 86.36 | 74.97 | 95.12 | 80.14 | 88.73 | 64.85 | 82.86 | 16.81 |
| HiFormer-B | 25.51 | 8.045 | 90.99 | 79.77 | 85.23 | 65.23 | 94.61 | 81.08 | 86.21 | 59.52 | 80.39 | 14.70 |
| DAEFormer | 48.07 | 27.89 | 91.82 | 82.39 | 87.66 | 71.65 | 95.08 | 80.77 | 87.84 | 63.93 | 82.63 | 16.39 |
| TransDeepLab | 21.14 | 16.31 | 89.00 | 79.88 | 84.08 | 69.16 | 93.53 | 78.40 | 86.04 | 61.19 | 80.16 | 21.25 |
| PVT-CASCADE | 35.28 | 6.40 | 90.1 | 80.37 | 82.23 | 70.59 | 94.08 | 83.69 | 83.01 | 64.43 | 81.06 | 20.23 |
| LKA Baseline | 85.82 | 13.62 | 91.45 | 81.93 | 84.93 | 71.05 | 94.87 | 83.71 | 87.48 | 66.76 | 82.77 | 17.42 |
| 2D D-LKA Net | 101.64 | 19.92 | 91.22 | 84.92 | 88.38 | 73.79 | 94.88 | 84.94 | 88.34 | 67.71 | 84.27 | 20.04 |
Skin lesions tab. 2. DSC, SE (sensitivity), SP (specificity), ACC for ISIC 2017, ISIC 2018 and PH2.
| Method | 2017 DSC | 2017 SE | 2017 SP | 2017 ACC | 2018 DSC | 2018 SE | 2018 SP | 2018 ACC | PH2 DSC | PH2 SE | PH2 SP | PH2 ACC |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| U-Net | 0.8159 | 0.8172 | 0.9680 | 0.9164 | 0.8545 | 0.8800 | 0.9697 | 0.9404 | 0.8936 | 0.9125 | 0.9588 | 0.9233 |
| Att-UNet | 0.8082 | 0.7998 | 0.9776 | 0.9145 | 0.8566 | 0.8674 | 0.9863 | 0.9376 | 0.9003 | 0.9205 | 0.9640 | 0.9276 |
| DAGAN | 0.8425 | 0.8363 | 0.9716 | 0.9304 | 0.8807 | 0.9072 | 0.9588 | 0.9324 | 0.9201 | 0.8320 | 0.9640 | 0.9425 |
| TransUNet | 0.8123 | 0.8263 | 0.9577 | 0.9207 | 0.8499 | 0.8578 | 0.9653 | 0.9452 | 0.8840 | 0.9063 | 0.9427 | 0.9200 |
| MCGU-Net | 0.8927 | 0.8502 | 0.9855 | 0.9570 | 0.8950 | 0.8480 | 0.9860 | 0.9550 | 0.9263 | 0.8322 | 0.9714 | 0.9537 |
| MedT | 0.8037 | 0.8064 | 0.9546 | 0.9090 | 0.8389 | 0.8252 | 0.9637 | 0.9358 | 0.9122 | 0.8472 | 0.9657 | 0.9416 |
| FAT-Net | 0.8500 | 0.8392 | 0.9725 | 0.9326 | 0.8903 | 0.9100 | 0.9699 | 0.9578 | 0.9440 | 0.9441 | 0.9741 | 0.9703 |
| TMU-Net | 0.9164 | 0.9128 | 0.9789 | 0.9660 | 0.9059 | 0.9038 | 0.9746 | 0.9603 | 0.9414 | 0.9395 | 0.9756 | 0.9647 |
| Swin-Unet | 0.9183 | 0.9142 | 0.9798 | 0.9701 | 0.8946 | 0.9056 | 0.9798 | 0.9645 | 0.9449 | 0.9410 | 0.9564 | 0.9678 |
| DeepLabv3+ (CNN) | 0.9162 | 0.8733 | 0.9921 | 0.9691 | 0.8820 | 0.8560 | 0.9770 | 0.9510 | 0.9202 | 0.8818 | 0.9832 | 0.9503 |
| HiFormer-B | 0.9253 | 0.9155 | 0.9840 | 0.9702 | 0.9102 | 0.9119 | 0.9755 | 0.9621 | 0.9460 | 0.9420 | 0.9772 | 0.9661 |
| LKA (Baseline) | 0.9229 | 0.9192 | 0.9824 | 0.9704 | 0.9118 | 0.8984 | 0.9802 | 0.9632 | 0.9409 | 0.9312 | 0.9759 | 0.9612 |
| 2D D-LKA Net | 0.9254 | 0.9327 | 0.9793 | 0.9705 | 0.9177 | 0.9164 | 0.9773 | 0.9647 | 0.9490 | 0.9430 | 0.9775 | 0.9659 |
Synapse, 3D tab. 3.
| Method | Params (M) | FLOPs (G) | Spl | RKid | LKid | Gal | Liv | Sto | Aor | Pan | DSC ↑ | HD95 ↓ |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| UNETR | 92.49 | 75.76 | 85.00 | 84.52 | 85.60 | 56.30 | 94.57 | 70.46 | 89.80 | 60.47 | 78.35 | 18.59 |
| Swin-UNETR | 62.83 | 384.2 | 95.37 | 86.26 | 86.99 | 66.54 | 95.72 | 77.01 | 91.12 | 68.80 | 83.48 | 10.55 |
| nnFormer | 150.5 | 213.4 | 90.51 | 86.25 | 86.57 | 70.17 | 96.84 | 86.83 | 92.04 | 83.35 | 86.57 | 10.63 |
| UNETR++ | 42.96 | 47.98 | 95.77 | 87.18 | 87.54 | 71.25 | 96.42 | 86.01 | 92.52 | 81.10 | 87.22 | 7.53 |
| LKA Baseline | 28.94 | 48.79 | 90.49 | 87.54 | 87.57 | 63.81 | 96.96 | 84.89 | 93.22 | 82.46 | 85.87 | 14.35 |
| D-LKA Net | 42.35 | 66.96 | 95.88 | 88.50 | 87.64 | 72.14 | 96.25 | 85.03 | 92.87 | 81.64 | 87.49 | 9.57 |
NIH Pancreas, 3D tab. 4.
| Method | Params (M) | FLOPs (G) | DSC ↑ | Jaccard ↑ | HD95 ↓ | ASD ↓ |
|---|---|---|---|---|---|---|
| UNETR | 92.45 | 63.53 | 77.42 | 63.95 | 15.07 | 5.09 |
| UNETR++ | 96.77 | 102.44 | 80.59 | 68.08 | 8.63 | 2.25 |
| D-LKA Net | 62.07 | 166.63 | 81.22 | 68.90 | 7.59 | 1.99 |
Ablations (Synapse, 3D) tab. 5 tab. 6.
| Variant | Params (M) | FLOPs (G) | DSC ↑ | HD95 ↓ |
|---|---|---|---|---|
| 3D LKA | 28.94 | 48.79 | 85.87 | 14.35 |
| 3D LKA + 3D conv. | 37.73 | 58.64 | 86.86 | 12.69 |
| 3D LKA + 3D deform. conv. (= D-LKA Net) | 42.35 | 66.96 | 87.49 | 9.57 |
| Skip connections | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| DSC ↑ | 84.78 | 85.99 | 86.56 | 87.07 | 87.49 |
| HD95 ↓ | 11.18 | 12.21 | 14.89 | 9.25 | 9.57 |
Parameter counts of the deformable layers tab. 7 app. A. Kernels are 21×21 nominal. Values for C = 32, 64, 128, 256, 512 channels.
| C | Standard conv | Decomposed conv | Deformable decomposed conv | Offset DDW-conv | Offset DDW-D conv |
|---|---|---|---|---|---|
| 32 | 451,584 | 3,392 | 197,204 | 40,050 | 153,762 |
| 64 | 1,806,336 | 8,832 | 396,308 | 80,050 | 307,426 |
| 128 | 7,225,344 | 25,856 | 800,660 | 160,050 | 614,754 |
| 256 | 28,901,376 | 84,480 | 1,633,940 | 320,050 | 1,229,410 |
| 512 | 115,605,504 | 300,032 | 3,398,804 | 640,050 | 2,458,722 |
Claims in the text.
- Synapse 2D: DSC 1.41 points above ScaleFormer and 1.64 above DAEFormer §3.3.1. Pancreas is said to be 2.04 points above the second-best method §3.3.1; see Pitfalls.
- Synapse 3D: DSC 0.27 above UNETR++ and 0.92 above nnFormer §3.3.2. HD95 is second-best §3.3.2 tab. 3.
- NIH Pancreas: best on all four metrics; DSC +0.63, Jaccard +0.82, HD95 −1.04, ASD −0.26 relative to UNETR++ §3.3.2 tab. 4.
- Parameter counts: 42.35 M is the lowest 3D parameter count in tab. 3; the text says only UNETR++ has fewer FLOPs §3.3.2 (see Pitfalls).
- Robustness: five training runs per method on Synapse 2D; the spleen is slightly worse; gallbladder, pancreas and stomach improve most §3.4 fig. 13. No run-to-run numbers are given in the text.
- Inference time: with a batch of 16 on 224×224 inputs, 8.01 ms with the deformable layer versus 17.38 ms without app. A fig. 7. The paper claims a speed-up only for batch sizes above 1 app. A.
- 2D parameters: 101.64 M, below ScaleFormer's 111.6 M and above most other 2D rows tab. 1 app. B fig. 8.
Paper vs code
Code: https://github.com/xmindflow/deformableLKA at d2d299267a765b07ca8956b18d94876e729e79f2 (cloned, depth 1). The paper links mindflow-institue/deformableLKA, which points to this repository; its owner is the xmindflow organisation, and an author's account appears in the commit history. The code has 2D/ and 3D/ subfolders, each with a MIT LICENSE; there is no root LICENSE. The two MIT files name different copyright holders (2D/LICENSE: Amirhossein Kazerouni, 2022; 3D/LICENSE: jsguo, 2021), so keep attribution to both when redistributing code. Code is cited, not quoted.
- Synapse 3D script uses the wrong block. The shipped Synapse script passes
--trans_block TransformerBlockrun_training_synapse.sh. That class is the UNETR++ EPA attention block with no LKA transformerblock.py. The D-LKA block isTransformerBlock_3D_single_deform_LKAtransformerblock.py. The pancreas script uses the D-LKA block train_pancreas.py. The paper does not say which block produced tab. 3, so the Synapse 3D number may need the flag changed to reproduce. - 2D batch size. The paper says 20 §3.1; the code default is 24 train_MaxViT_deform_LKA.py. The script scales the base learning rate by batch/24 when the batch is not 24 and is a multiple of 5 train_MaxViT_deform_LKA.py. At batch 20 with base LR 0.05, the code gives 0.05 × 20/24 ≈ 0.0417 (our arithmetic).
- 2D learning-rate schedule. Not stated in the paper; the code decays the LR polynomially with power 0.9 per iteration over
max_epochs × iterations per epochtrainer_MaxViT_deform_LKA.py trainer_MaxViT_deform_LKA.py. - 3D optimiser details. Paper: SGD, LR 0.01, weight decay 3e-5 §3.1; code matches these d_lka_former_trainer_synapse.py Trainer_synapse.py. The code also sets Nesterov momentum 0.99 d_lka_former_trainer_synapse.py and decays the LR with power 0.9 per epoch d_lka_former_trainer_synapse.py. If the mean foreground Dice is zero at epoch 100, the trainer lowers momentum to 0.95 d_lka_former_trainer_synapse.py. None of these is in the paper.
- 3D loss. The paper's loss (eq. 14) is written in the 2D paragraph and the 3D loss is not stated. The code uses Dice + cross-entropy with weights 1 and 1, sum aggregation, smooth 1e-5, background excluded Trainer_synapse.py dice_loss.py. Deep supervision weights halve per level and are normalised d_lka_former_trainer_synapse.py. Neither is in the paper.
- 3D patch size. Paper: 128 × 128 × 64 §3.1. The trainer sets
crop_size = [64, 128, 128]d_lka_former_trainer_synapse.py, but the training patch size is read from the plans file Trainer_synapse.py. The plans file is not in the repository, so the effective patch size and axis order cannot be confirmed. - 3D batch size. Paper: 2 §3.1. The code reads it from the plans file Trainer_synapse.py, which is not in the repository.
- 3D block differs from eq. 12 and 13. The code's block scales the attention branch by a learnable per-channel
gamma, initialised to 1e-6 transformerblock.py transformerblock.py. The convolution after attention is a residual UNet block with batch normalisation transformerblock.py, and the output projection is preceded by dropout (rate 0.1) transformerblock.py. The paper's equations show none of these. - 3D deformable layer. Paper: "a sole deformable convolution layer" after the depthwise convolutions §2.2; kernel not stated. Code: standard depthwise 5×5×5 and 7×7×7 (dilation 3) convolutions, then one deformable 3×3×3 convolution with
in = out = dim, which is not depthwise transformerblock.py. The 3D deformable convolution needs a custom build README.md (dcn/make.sh). - NIH Pancreas script. The paper gives no training hyperparameters §3.2. The released script uses SGD with LR 0.01, momentum 0.9, weight decay 1e-4, batch 8 with one labelled sample, 6000 iterations, 96³ patches, and LR ×0.1 every 2500 iterations train_pancreas.py train_pancreas.py train_pancreas.py train_pancreas.py. The loss is cross-entropy + Dice on the labelled part only train_pancreas.py. A consistency-weight function is defined train_pancreas.py but I did not find it added to
loss_total. Whether this script produced tab. 4 is not stated. - Skin scripts. The paper gives no skin training hyperparameters. The skin scripts default to batch 4, LR 0.01, SGD momentum 0.9, weight decay 1e-4 train_skin.py train_skin.py train_skin.py. They carry their own model copies under
2D/skin_code/model/; I did not compare these with the main 2D network. - Kernel span. The code's two depthwise kernels (5×5, then 7×7 at dilation 3) cover a combined span of 5 + 3·6 = 23 pixels (our arithmetic). The paper's nominal kernel is 21×21 app. A deformable_LKA.py.
- Paper's 2D code path matches the design. Four MaxViT encoder stages, four decoder stages with two D-LKA blocks each, and the 2D deformable offsets are all implemented MaxViT_deform_LKA.py MaxViT_deform_LKA.py.
- Paths and data. The Synapse script hard-codes
/home/leon/repos/deformableLKA/3D/DATASETrun_training_synapse.sh, and the README asks users to rename folders containingunetr_pptod_lka_formerREADME.md.
No discrepancies were found for the 2D loss weights (0.6 Dice, 0.4 CE), SGD momentum 0.9, 2D weight decay, 2D epochs (400), 3D epochs (1000), 3D learning rate (0.01), 3D weight decay (3e-5), or 250 patches per epoch.
Pitfalls
- Printed derivative has a sign error. Eq. 5 is written as C(8d̂ + 2K²/d̂³ − 4), which has no positive root for K = 21. With the sign of the 2K²/d̂³ term flipped to minus, d ≈ 3.37 comes out (our check). The derivative also ignores the ceiling in eq. 3.
- Table 7 and eq. 3 disagree by a term. The "decomposed" column equals C(⌈K/d⌉² + (2d−1)² + C) for every row (C = 32: 32·(49 + 25 + 32) = 3,392). Eq. 3 adds "+3" that the table does not include (our arithmetic). The offset columns are full convolutions, not depthwise, which is why offsets dominate the deformable parameter cost app. A.
- Text disagrees with Table 3 on FLOPs. The text says only UNETR++ has fewer FLOPs than D-LKA Net §3.3.2. In tab. 3 the LKA Baseline (48.79 G) and UNETR++ (47.98 G) both have fewer; D-LKA Net (66.96 G) is third lowest.
- Text disagrees with Table 1 on the pancreas margin. The text says pancreas DSC is 2.04 points above the second-best method §3.3.1. In tab. 1 the second-best pancreas value is 66.76 (LKA Baseline), a margin of 0.95 points. The 2.04 figure is measured against MISSFormer (65.67).
- Text overstates the skin results. The paper says D-LKA Net "consistently outperforms its competitors across various evaluation metrics" §3.3.1. In tab. 2 it has the best DSC on all three sets, but its specificity (SP) is not the best on any of them (DeepLabv3+ leads on ISIC 2017 and PH2; Att-UNet on ISIC 2018).
- 2D HD95 is not the best. D-LKA Net's 2D HD95 is 20.04 tab. 1; several methods are lower (HiFormer-B 14.70, DAEFormer 16.39, ScaleFormer 16.81, LeViT-UNet 16.84). The text does not discuss HD95 for 2D.
- Pancreas FLOPs are the highest in Table 4. D-LKA Net has 166.63 G versus 63.53 G (UNETR) and 102.44 G (UNETR++) tab. 4. The text reports only parameters.
- Robustness has no numbers in the text. The "statistical significance" claim §3.4 rests on five runs shown only in fig. 13. The text names no test and gives no variance figures.
- Baseline numbers may be copied. A commented-out caption line in the source says the baseline rows were "aggregated from" earlier papers tab. 1 source. The visible text does not say whether they were re-run.
- Split and augmentation details are missing. The ISIC 2018 split and the PH2 split are not stated §3.2. The augmentations are only named by reference to TransUNet, nnFormer and UNETR++ §3.1. Test-time procedure and the HD95 definition are not given.
- Speed claim is narrow. Timing uses random 224×224 inputs, 1000 runs after 50 warm-up iterations on an RTX 3090 app. A. The paper claims a speed-up only for batch sizes above 1 app. A.
- 3D needs a custom build. The 3D deformable convolution is a CUDA op built from
3D/dcn/make.shREADME.md; the 2D path usestorchvision.ops.DeformConv2ddeformable_LKA.py. - Encoder initialisation not checked. The paper does not say whether the MaxViT encoder is pretrained. The 2D training script has resume and checkpoint options but no pretrained-weights argument train_MaxViT_deform_LKA.py; I did not check the model constructor.
- Decoder and MLP kernels. The paper's MLP depthwise kernel and the 3D Conv3 kernels are not stated §2.3 §2.4.
- Layer count in 3D. The release defaults to depths 3 run_training_synapse.sh but the bottleneck depth is not confirmed in the release.
Lineage
- Builds on: Large Kernel Attention, Guo et al. (arXiv:2202.09741), which D-LKA revisits and extends §2.1. Deformable convolutions, Dai et al. §2.2. The MaxViT encoder, Tu et al. §2.3. The 3D training recipe follows nnFormer and UNETR++ §3.1; the nnFormer card is nnFormer.
- Compared against (2D, Synapse): TransUNet, Swin-UNet, LeViT-UNet-384, MISSFormer, ScaleFormer, HiFormer-B, DAEFormer, TransDeepLab, PVT-CASCADE, LKA Baseline tab. 1. Skin: U-Net, Att-UNet, DAGAN, TransUNet, MCGU-Net, MedT, FAT-Net, TMU-Net, Swin-Unet, DeepLabv3+, HiFormer-B, LKA Baseline tab. 2. 3D Synapse: UNETR, Swin-UNETR, nnFormer, UNETR++, LKA Baseline tab. 3. Pancreas: UNETR, UNETR++ tab. 4.
- Superseded by: not known from content in this wiki.
Source and license
Adapted from “Beyond Self-Attention: Deformable Large Kernel Attention for Medical Image Segmentation” by Reza Azad, Leon Niggemeier, Michael Huttemann, Amirhossein Kazerouni, Ehsan Khodapanah Aghdam, Yury Velichko, Ulas Bagci, Dorit Merhof (arXiv:2309.00121), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/xmindflow/deformableLKA at commit d2d299267a76 (MIT). Any quoted code is shown under that license.