yolov4 darknet 源码学习笔记(一) yolov4.cfg文件各参数含义

yolov4 darknet 源码学习笔记(一)cfg文件各参数含义

paper: https://arxiv.org/abs/2004.10934
github: https://github.com/AlexeyAB/darknet
感谢AlexeyAB大神分享

[net]

网络参数模块

batch=64 # batch size
subdivisions=8 # batch size 细分,训练中每次推理batch/subdivisions(64/8)幅图片,计算loss时使用batch(64)幅累加

Training

#width=512
#height=512
width=608 # 输入图片统一尺寸为608 *608 *3
height=608
channels=3
momentum=0.949 # 动量 加速学习,特别是处理高曲率、小但一致的梯度,或是带噪声的梯度。动量算法累计之前梯度指数级衰减的移动平均,并且继续沿着该方向移动。详细公式请见《花书》第8章第三节
decay=0.0005 # 权重衰减正则项,防止过拟合
angle=0 # 旋转角度,数据增强参数
saturation = 1.5 # 数据增强参数HSV彩色模型:饱和度
exposure = 1.5 # 曝光度
hue=.1 # 色调

learning_rate=0.0013 # 学习率 ,学习率设置机制:https://zhuanlan.zhihu.com/p/28893986
burn_in=1000 # 迭代次数>burn_in*3时,使用policy策略
max_batches = 500500 # 最大迭代次数
policy=steps # 学习率调整策略:CONSTANT, STEP, EXP, POLY, STEPS, SIG, RANDOM, SGDR
steps=400000,450000
scales=.1,.1 # steps 和scales为学习率调整策略参数。当迭代到400000次时,学习率衰减10倍;当迭代到450000次时,学习率再衰减10倍

#cutmix=1 #是否使用cutmix数据增强
mosaic=1 # 是否使用mosaic数据增强

#:104x104 54:52x52 85:26x26 104:13x13 for 416

第一个卷积层

[convolutional]
batch_normalize=1 #使用batch_normalize
filters=32 #卷积核输出通道32,此层输入尺寸=608×608×3,输出尺寸=608×608×32,总共参数=333*32
size=3 #卷积核尺寸,3×3
stride=1 #卷积步长1
pad=1 # 边界填充1
activation=mish # 激活函数

Backbone中5个CSPnet层,特征图大小一次从608变为304->152->76->38->19。为避免篇幅过长,本文仅展示第一个CSPnet

CSPnet

[convolutional]
batch_normalize=1
filters=64
size=3
stride=2
pad=1
activation=mish

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=mish

[route]
layers = -2

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=mish

[convolutional]
batch_normalize=1
filters=32
size=1
stride=1
pad=1
activation=mish

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=mish

[shortcut] # add层
from=-3
activation=linear

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=mish

[route] # 等于常说的cancat层
layers = -1,-7

[convolutional]
batch_normalize=1
filters=64
size=1
stride=1
pad=1
activation=mish

End CSPnet




##########################

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

SPP

[maxpool]
stride=1
size=5

[route]
layers=-2

[maxpool]
stride=1
size=9

[route]
layers=-4

[maxpool]
stride=1
size=13

[route]
layers=-1,-3,-5,-6

End SPP

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

FPN

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = 85

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[route]
layers = -1, -3

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = 54

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[route]
layers = -1, -3

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

End FPN

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

##########################

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=256
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

YOLO 层

[yolo]
mask = 0,1,2 # 使用anchor的索引,0,1,2表示使用下面定义的anchors中的前三对anchors
anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
classes=80 # 类别数目
num=9 # anchors对数
jitter=.3 # 数据增强手段,缩放抖动系数,对原始图片进行宽高方向上的插值缩放(两方向上缩放系数不一定相同)
ignore_thresh = .7 # iou>ignore_thresh认为是正样本
truth_thresh = 1 # 真实框的iou值
scale_x_y = 1.2 # 为加快收敛,在anchor->预测框过程中,将中心点偏移范围0-1,映射到-0.1-1.1
iou_thresh=0.213 # 如果某个真实框和某个anchor的iou大于此阈值,则这个anchor负责预测这个真是框
cls_normalizer=1.0 # 计算分类损失的正则化系数,计算分类梯度时的衰减系数
iou_normalizer=0.07 # 计算边界回归损失的正则化系数,计算边界回归梯度时的衰减系数
iou_loss=ciou # 边界框回归损失函数,支持: MSE, IOU Loss, GIOU Loss, DIOU Loss, CIOU Loss.
nms_kind=greedynms # nms种类,支持:CORNERS_NMS,GREEDY_NMS,DIOU_NMS
beta_nms=0.6 # diou_nms 超参
max_delta=5 # 在iou loss 不是MSE时(iou loss: IOU, GIOU, MSE, DIOU, CIOU),dx, dy, dh, dw的取值范围[-max_delta, max_delta]

PAN

[route]
layers = -4

[convolutional]
batch_normalize=1
size=3
stride=2
pad=1
filters=256
activation=leaky

[route]
layers = -1, -16

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

End PAN

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 3,4,5
anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
scale_x_y = 1.1
iou_thresh=0.213
cls_normalizer=1.0
iou_normalizer=0.07
iou_loss=ciou
nms_kind=greedynms
beta_nms=0.6
max_delta=5

PAN

[route]
layers = -4

[convolutional]
batch_normalize=1
size=3
stride=2
pad=1
filters=512
activation=leaky

[route]
layers = -1, -37

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

End PAN

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=1024
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 6,7,8
anchors = 12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401
classes=80
num=9
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1 # 是否使用随机多尺度训练
scale_x_y = 1.05
iou_thresh=0.213
cls_normalizer=1.0
iou_normalizer=0.07
iou_loss=ciou
nms_kind=greedynms
beta_nms=0.6
max_delta=5

如有错误欢迎指出,谢谢观看!

你可能感兴趣的:(darknet,深度学习)