Article · 2025-04-03

Reproducing DeepLabV3+ with PaddlePaddle 2.x (Part 1): Construction and Training

Model Construction: Object-Oriented Implementation

We built DeepLabV3+ as a modular class following the paddle.nn.Layer interface:

The final model follows an encoder-decoder architecture that outputs segmentation maps at the input resolution.

Model structure:

class DeepLabV3Plus(nn.Layer):
    def __init__(self, num_classes):
        super().__init__()
        self.entry = ...
        self.block1 = XceptionBlock(...)
        ...
        self.aspp = ASPP(...)
        self.decoder = ...
        self.final = ...

    def forward(self, x):
        ... # 完整结构见文末源码

Training Pipeline

The training loop uses paddle.io.DataLoader and the standard nn.Layer interface:

Training implementation:

model = DeepLabV3Plus(num_classes=21)
optimizer = paddle.optimizer.Adam(...)
criterion = CrossEntropyLossWithMask(ignore_index=255)

for epoch in range(num_epochs):
    for imgs, labels in dataloader:
        preds = model(imgs)
        loss = criterion(preds, labels)
        loss.backward()
        optimizer.step()
        optimizer.clear_grad()

Currently, training runs on DummySegDataset for development. Swap this for PASCAL VOC, ADE20K, or other datasets as needed.


Validation, metrics, and deployment follow in subsequent posts.

© 2026 Yuxu Ge ·