1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""Residual U-Net for image segmentation
5
6A semantic segmentation neural network which combines the strengths of residual
7learning and U-Net is proposed for road area extraction. The network is built
8with residual units and has similar architecture to that of U-Net. The benefits
9of this model is two-fold: first, residual units ease training of deep
10networks. Second, the rich skip connections within the network could facilitate
11information propagation, allowing us to design networks with fewer parameters
12however better performance.
13
14Reference: [ZHANG-2017]_
15"""
16
17from torch.optim.lr_scheduler import MultiStepLR
18
19from bob.ip.binseg.engine.adabound import AdaBound
20from bob.ip.binseg.models.losses import SoftJaccardBCELogitsLoss
21from bob.ip.binseg.models.resunet import resunet50
22
23# config
24lr = 0.001
25betas = (0.9, 0.999)
26eps = 1e-08
27weight_decay = 0
28final_lr = 0.1
29gamma = 1e-3
30eps = 1e-8
31amsbound = False
32
33scheduler_milestones = [900]
34scheduler_gamma = 0.1
35
36model = resunet50()
37
38# optimizer
39optimizer = AdaBound(
40 model.parameters(),
41 lr=lr,
42 betas=betas,
43 final_lr=final_lr,
44 gamma=gamma,
45 eps=eps,
46 weight_decay=weight_decay,
47 amsbound=amsbound,
48)
49
50# criterion
51criterion = SoftJaccardBCELogitsLoss(alpha=0.7)
52
53# scheduler
54scheduler = MultiStepLR(
55 optimizer, milestones=scheduler_milestones, gamma=scheduler_gamma
56)