yolov8训练参数讲解
最佳答案 问答题库868位专家为你答疑解惑
训练命令:
yolo train model = yolov8x.pt data = myhand.yaml epochs = 350 batch=8
使用 nohup命令在linux服务器上挂载训练并保留日志的命令如下:
nohup yolo train model = yolov8x.pt data = myhand.yaml epochs = 350 batch=8 > result20231101.out 2>&1&
实际训练中的参数呈现:
task=detect, mode=train, model=yolov8n.pt, data=myhand.yaml, epochs=20, patience=50, batch=16,
imgsz=640, save=True, save_period=-1, cache=False, device=None, workers=8, project=None, name=None,
exist_ok=False, pretrained=True, optimizer=auto, verbose=True, seed=0, deterministic=True, single_cls=False,
rect=False, cos_lr=False, close_mosaic=10, resume=False, amp=True, fraction=1.0, profile=False, overlap_mask=True,mask_ratio=4, dropout=0.0, val=True, split=val, save_json=False, save_hybrid=False, conf=None, iou=0.7, max_det=300, half=False, dnn=False, plots=True, source=None, show=False, save_txt=False, save_conf=False, save_crop=False, show_labels=True, show_conf=True, vid_stride=1, line_width=None, visualize=False, augment=False, agnostic_nms=False, classes=None, retina_masks=False, boxes=True, format=torchscript, keras=False, optimize=False, int8=False, dynamic=False, simplify=False,opset=None, workspace=4, nms=False, lr0=0.01, lrf=0.01, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=7.5, cls=0.5, dfl=1.5, pose=12.0, kobj=1.0, label_smoothing=0.0, nbs=64, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=0.0, translate=0.1, scale=0.5, shear=0.0, perspective=0.0, flipud=0.0, fliplr=0.5, mosaic=1.0, mixup=0.0, copy_paste=0.0, cfg=None, tracker=botsort.yaml, save_dir=runs/detect
关于参数的讲解:
官网(Ultralytics YOLOv8 Modes - Ultralytics YOLOv8 Docs)提供的全部参数展示:
Arguments
Training settings for YOLO models refer to the various hyperparameters and configurations used to train the model on a dataset. These settings can affect the model's performance, speed, and accuracy. Some common YOLO training settings include the batch size, learning rate, momentum, and weight decay. Other factors that may affect the training process include the choice of optimizer, the choice of loss function, and the size and composition of the training dataset. It is important to carefully tune and experiment with these settings to achieve the best possible performance for a given task(YOLO模型的训练设置是指用于在数据集上训练模型的各种超参数和配置。这些设置可能会影响模型的性能、速度和精度。一些常见的YOLO训练设置包括批量大小、学习率、动量和权重衰减。可能影响训练过程的其他因素包括优化器的选择、损失函数的选择以及训练数据集的大小和组成。重要的是要仔细调整和试验这些设置,以实现给定任务的最佳性能).
model
None
path to model file, i.e. yolov8n.pt, yolov8n.yamldata
None
path to data file, i.e. coco128.yamlepochs
100
number of epochs to train forpatience
50
epochs to wait for no observable improvement for early stopping of trainingbatch
16
number of images per batch (-1 for AutoBatch)imgsz
640
size of input images as integersave
True
save train checkpoints and predict resultssave_period
-1
Save checkpoint every x epochs (disabled if < 1)cache
False
True/ram, disk or False. Use cache for data loadingdevice
None
device to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpuworkers
8
number of worker threads for data loading (per RANK if DDP)project
None
project namename
None
experiment nameexist_ok
False
whether to overwrite existing experimentpretrained
True
(bool or str) whether to use a pretrained model (bool) or a model to load weights from (str)optimizer
'auto'
optimizer to use, choices=[SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, auto]verbose
False
whether to print verbose outputseed
0
random seed for reproducibilitydeterministic
True
whether to enable deterministic modesingle_cls
False
train multi-class data as single-classrect
False
rectangular training with each batch collated for minimum paddingcos_lr
False
use cosine learning rate schedulerclose_mosaic
10
(int) disable mosaic augmentation for final epochs (0 to disable)resume
False
resume training from last checkpointamp
True
Automatic Mixed Precision (AMP) training, choices=[True, False]fraction
1.0
dataset fraction to train on (default is 1.0, all images in train set)profile
False
profile ONNX and TensorRT speeds during training for loggersfreeze
None
(int or list, optional) freeze first n layers, or freeze list of layer indices during traininglr0
0.01
initial learning rate (i.e. SGD=1E-2, Adam=1E-3)lrf
0.01
final learning rate (lr0 * lrf)momentum
0.937
SGD momentum/Adam beta1weight_decay
0.0005
optimizer weight decay 5e-4warmup_epochs
3.0
warmup epochs (fractions ok)warmup_momentum
0.8
warmup initial momentumwarmup_bias_lr
0.1
warmup initial bias lrbox
7.5
box loss gaincls
0.5
cls loss gain (scale with pixels)dfl
1.5
dfl loss gainpose
12.0
pose loss gain (pose-only)kobj
2.0
keypoint obj loss gain (pose-only)label_smoothing
0.0
label smoothing (fraction)nbs
64
nominal batch sizeoverlap_mask
True
masks should overlap during training (segment train only)mask_ratio
4
mask downsample ratio (segment train only)dropout
0.0
use dropout regularization (classify train only)val
True
validate/test during training
1. model ✰✰✰✰✰
model
: 模型文件的路径。这个参数指定了所使用的模型文件的位置,例如 yolov8n.pt
或 yolov8n.yaml
。
2. data ✰✰✰✰✰
data
: 数据文件的路径。该参数指定了数据集文件的位置,例如 coco128.yaml
。数据集文件包含了训练和验证所需的图像、标签。
3. epochs ✰✰✰
epochs
: 训练的轮数。这个参数确定了模型将会被训练多少次,每一轮都遍历整个训练数据集。训练的轮数越多,模型对数据的学习就越充分,但也增加了训练时间。
4. patience
patience
: 早停的等待轮数。在训练过程中,如果在一定的轮数内没有观察到模型性能的明显提升,就会停止训练。这个参数确定了等待的轮数,如果超过该轮数仍没有改进,则停止训练。
5. batch ✰✰✰✰✰
batch
: 每个批次中的图像数量。在训练过程中,数据被分成多个批次进行处理,每个批次包含一定数量的图像。这个参数确定了每个批次中包含的图像数量。特殊的是,如果设置为**-1**,则会自动调整批次大小,至你的显卡能容纳的最多图像数量。
6. imgsz ✰✰✰✰✰
imgsz
: 输入图像的尺寸。这个参数确定了输入图像的大小。可以指定一个整数值表示图像的边长,也可以指定宽度和高度的组合。例如640
表示图像的宽度和高度均为640像素。
7. save、save_period ✰✰✰
-
save
: 是否保存训练的检查点和预测结果。当训练过程中保存检查点时,模型的权重和训练状态会被保存下来,以便在需要时进行恢复或继续训练。预测结果也可以被保存下来以供后续分析和评估。
8. cache
cache
: 数据加载时是否使用缓存。这个参数控制是否将数据加载到缓存中,以加快训练过程中的数据读取速度。可以选择在 RAM 内存中缓存数据(True/ram)、在磁盘上缓存数据(disk)或不使用缓存(False)。
9. device ✰✰✰✰✰
device
: 训练运行的设备。该参数指定了模型训练所使用的设备,例如使用 GPU 运行可以指定为 cuda device=0
,或者使用多个 GPU 运行可以指定为 device=0,1,2,3
,如果没有可用的 GPU,可以指定为 device=cpu
使用 CPU 进行训练。
10. workers ✰✰✰
workers
: 数据加载时的工作线程数。在数据加载过程中,可以使用多个线程并行地加载数据,以提高数据读取速度。这个参数确定了加载数据时使用的线程数,具体的最佳值取决于硬件和数据集的大小。
11. project
project
: 项目名称。这个参数用于标识当前训练任务所属的项目,方便管理和组织多个训练任务。
12. name
name
: 实验名称。该参数为当前训练任务指定一个名称,以便于标识和区分不同的实验。
13. exist_ok
exist_ok
: 是否覆盖现有的实验。如果设置为 True,当实验名称已经存在时,将会覆盖现有实验。如果设置为 False,当实验名称已经存在时,将会报错。
14. pretrained
pretrained
: 是否使用预训练模型。如果设置为 True,将加载预训练的模型权重进行训练,这有助于加快训练过程和提高模型性能。
15. optimizer
optimizer
: 选择要使用的优化器。优化器是深度学习中用于调整模型参数以最小化损失函数的算法。可以选择不同的优化器,如 ‘SGD’、‘Adam’、‘AdamW’、‘RMSProp’,根据任务需求选择适合的优化器。
16. verbose
verbose
: 是否打印详细输出。如果设置为 True,训练过程中会输出更详细的信息和日志。如果设置为 False,只会输出关键信息和结果。
17. seed
seed
: 随机种子,用于实现可重复性。通过设置相同的随机种子,可以使得每次运行时的随机过程保持一致,以便于结果的复现。
18. deterministic
deterministic
: 是否启用确定性模式。启用确定性模式后,保证在相同的输入下,每次运行的结果是确定的,不会受到随机性的影响。
19. single_cls
single_cls
: 将多类数据训练为单类。如果设置为 True,将会将多类数据视为单一类别进行训练。
20. rect
rect
: 使用矩形训练,每个批次进行最小填充。设置为 True 后,训练过程中使用矩形形状的图像批次,并进行最小化填充。
21. cos_lr
cos_lr
: 使用余弦学习率调度器。如果设置为 True,将使用余弦函数调整学习率的变化情况。
22. close_mosaic
close_mosaic
: 禁用mosaic增强的最后第几个轮次。可以指定一个整数值,表示在训练的最后第几个轮次中禁用mosaic增强。
23. resume
resume
: 从最后一个检查点恢复训练。如果设置为 True,将从最后一个检查点的状态继续训练。
24. amp
amp
: 是否使用自动混合精度(Automatic Mixed Precision,AMP)训练。AMP 是一种深度学习训练技术,利用半精度浮点数加速训练过程,可以减少显存占用。
25. lr0
lr0
: 初始学习率。学习率是控制模型参数更新步幅的超参数,初始学习率确定了训练开始时的参数更新速度。
26. lrf
lrf
: 最终学习率。最终学习率是通过初始学习率乘以一个比例系数得到的,用于控制训练过程中学习率的衰减。
27. momentum
momentum
: SGD 优化器的动量/Adam 优化器的 beta1。动量是一种加速梯度下降过程的技术,用于增加参数更新的稳定性。
28. weight_decay
weight_decay
: 优化器的权重衰减(weight decay)。权重衰减是一种正则化技术,用于减小模型复杂度,防止过拟合。
29. warmup_epochs
warmup_epochs
: 热身阶段的轮数。热身阶段是训练过程中初始阶段的一部分,在此阶段内,学习率和动量等参数逐渐增加,以帮助模型更好地适应训练数据。
30. warmup_momentum
warmup_momentum
: 热身阶段的初始动量。在热身阶段开始时,动量的初始值。
31. warmup_bias_lr
warmup_bias_lr
: 热身阶段的初始偏置学习率。在热身阶段开始时,偏置学习率的初始值。
32. box、cls
box
: 边界框损失权重。用于调整边界框损失的权重,以控制其在总损失中的贡献程度。cls
: 类别损失权重。用于调整类别损失的权重,以控制其在总损失中的贡献程度(按像素进行缩放)。
33. dfl
dfl
: DFL(Dynamic Freezing Loss)损失权重。用于调整 DFL 损失的权重,以控制其在总损失中的贡献程度。
34. pose
pose
: 姿态损失权重(仅姿态)。用于调整姿态损失的权重,以控制其在总损失中的贡献程度(仅应用于姿态相关任务)。
35. kobj
kobj
: 关键点目标损失权重(仅姿态)。用于调整关键点目标损失的权重,以控制其在总损失中的贡献程度(仅应用于姿态相关任务)。
36. label_smoothing
label_smoothing
: 标签平滑(label smoothing)。标签平滑是一种正则化技术,用于减少模型对训练数据的过拟合程度。
37. nbs
nbs
: 标准批次大小(nominal batch size)。指定训练过程中每个批次的大小。
38. overlap_mask
overlap_mask
: 训练时是否要求蒙版重叠(仅用于分割训练)。如果设置为 True,要求训练过程中的蒙版(mask)重叠。
39. mask_ratio
mask_ratio
: 蒙版下采样比例(仅用于分割训练)。用于控制蒙版下采样的比例。
40. dropout
dropout
: 是否使用丢弃正则化(dropout regularization)(仅用于分类训练)。如果设置为非零值,则在训练过程中使用丢弃正则化来减少模型的过拟合。
41. val
val
: 是否在训练过程中进行验证/测试。如果设置为 True,将在训练过程中进行验证或测试,以评估模型的性能。
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"yolov8训练参数讲解":http://eshow365.cn/6-36190-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!