ベースライン モデル
XFPN は、セグメンテーション タスク用のネットワークです。主に GoogleNet_v1 と FPN で構成されています。ネットワークの最後の数レイヤーは次のように定義されます。
layer {
bottom: "add_p2"
top: "pred"
name: "toplayer_p2"
type: "Deconvolution"
convolution_param {
num_output: 19
kernel_size: 4
pad: 1
stride: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "pred"
bottom: "label"
top: "loss"
loss_weight: 1
include {
phase: TRAIN
}
loss_param {
ignore_label: 255
}
}
layer {
name: "result"
type: "Softmax"
bottom: "pred"
top: "result"
include {
phase: TEST
}
}
layer {
name: "segmentation_eval_classIOU"
type: "SegmentPixelIOU"
bottom: "result"
bottom: "label"
top: "segmentation_eval"
include {
phase: TEST
}
}
コンフィギュレーション ファイルを作成する
config.prototxt という名前のファイルを作成します。
workspace: "./workspace/segmentation/pruning"
gpu: "0,1,2,3"
#test_iter = validation_data_number/val_batch_size e.g. 500/4
test_iter: 125
acc_name: "segmentation_eval_classIOU"
eval_type: "segmentation"
# dataset classes number #e.g. cityscapes: 19
classiou_class_num: 19
model: "./workspace/segmentation/trainval.prototxt"
weights: "./workspace/segmentation/snapshots/_iter_200000.caffemodel"
solver: "./workspace/segmentation/solver.prototxt"
rate: 0.1
pruner {
method: REGULAR
exclude {
layer_top: "pred"
}
}
モデル解析を実行する
$ ./vai_p_caffe ana –config config.prototxt
モデルをプルーニングする
$ ./vai_p_caffe prune –config config.prototxt
プルーニング済みモデルを微調整する
微調整の初期パラメーターとして、次のソルバー設定を使用できます。
net: "./workspace/segmentation/trainval.prototxt"
test_iter: 125
test_interval: 5000
test_initialization: true
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.01
momentum: 0.9
weight_decay: 0.0005
# The learning rate policy
lr_policy: "multistep"
gamma: 0.1
stepvalue: 75000
stepvalue: 85000
display: 10
max_iter: 200000
snapshot: 5000
snapshot_prefix: "./workspace/segmentation/snapshots/"
solver_mode: GPU
iter_size: 1
average_loss: 20
eval_type: "segmentation"
classiou_class_num: 19
次のコマンドを使用して微調整を開始します。
$ ./vai_p_caffe finetune -config config.prototxt
推定所要時間: Cityscapes の学習用データセットを使用した場合、270 エポックで約 40 時間 (2975 画像、4 x NVIDIA Tesla V100)。
最終出力を生成する
モデルを完成させるには、次を実行します。
$ ./vai_p_caffe transform –model baseline.prototxt –weights finetuned_model.caffemodel -output
final.caffemodel
プルーニングの結果
- データセット
- Cityscapes
- 入力サイズ
- 2048 x 1024
- GPU プラットフォーム
- 4 x NVIDIA Tesla V100
- FLOPs
- 136G
丸め処理 | FLOPs | mIOU |
---|---|---|
0 | 100% | 71.25 |
1 | 90% | 70.88 |
2 | 83% | 69.94 |