遇见 YOLO26: 下一代视觉 AI。
Ultralytics
返回 Ultralytics 词汇表

Learning Rate

了解学习率如何影响模型训练。探索如何为 Ultralytics YOLO26 优化步长,以在目标检测等任务中实现 SOTA 性能。

学习率是一项关键的超参数调优配置,它决定了模型在优化过程中所采取的步长。在训练神经网络时,它控制模型在每次处理一批数据并根据估计误差进行调整时,其内部权重更新的幅度。可以把它想象成一个人正走下山前往山谷(误差最低点);学习率决定了此人步伐的大小。如果步幅太大,他们可能会直接跨过山谷而错过谷底。如果步幅太小,到达目的地可能需要耗费不切实际的漫长时间。

Link to this section优化中的“金发姑娘”困境#

Finding the optimal learning rate is often described as a balancing act within machine learning workflows. The goal is to minimize the loss function, which measures the difference between the model's predictions and the actual ground truth. This process relies heavily on an optimization algorithm such as stochastic gradient descent (SGD) or the Adam optimizer to navigate the loss landscape.

  • Learning Rate Too High: If the value is set too high, the model's weight updates will be drastic. This can lead to the "overshooting" phenomenon, where the model fails to converge on a solution and instead oscillates wildly or diverges. This instability can sometimes trigger an exploding gradient problem, rendering the training process useless.
  • Learning Rate Too Low: Conversely, an extremely small step size ensures that the model moves carefully towards the minimum, but it can result in underfitting because the training process becomes agonizingly slow. The model might effectively get stuck in a local minimum or take thousands of extra epochs to learn simple patterns, computationally wasting resources. Researchers often consult the PyTorch documentation on optimization to understand how different algorithms interact with these values.

Link to this section实际应用#

学习率调整的影响在部署了计算机视觉任务的各种高风险行业中显而易见。

  1. Autonomous Driving Systems: In the development of autonomous vehicles, engineers utilize vast datasets to train models for object detection to identify pedestrians and traffic signs. When applying transfer learning to a pre-trained model like YOLO26, developers typically use a much smaller learning rate than they would during initial training. This "fine-tuning" ensures that the model learns the nuances of specific driving environments (e.g., snowy roads vs. desert highways) without erasing the general feature extraction capabilities it already possesses.

  2. Medical Diagnostic Imaging: In medical image analysis, such as detecting tumors in MRI scans, precision is paramount. A high learning rate here creates a risk of the model skipping over subtle texture differences that distinguish malignant tissue from benign tissue. Practitioners often employ a technique called "learning rate warmup," gradually increasing the rate from zero to a target value to stabilize the early stages of training, ensuring the neural network weights settle into a stable configuration before aggressive learning begins. You can read more about these strategies in the Google Machine Learning Crash Course.

Link to this section区分相关术语#

将学习率与其他训练参数区分开来非常重要,因为它们通常配置在相同的配置文件中,但用途各不相同:

  • Learning Rate vs. Batch Size: While the learning rate controls the magnitude of the update, the batch size determines the number of training samples processed before an update occurs. There is a strong relationship between the two; often, when increasing the batch size, one must also scale up the learning rate to maintain training efficiency, a concept explored in papers on large-batch training.
  • 学习率 vs. 衰减: 衰减是指一种随着时间推移系统地降低学习率的策略。调度器可能会每 30 个轮次将学习率降低 10 倍。这有助于模型在早期进行大幅度的概念跳跃,并在训练后期通过更小的步长来精炼其准确性。这是 Ultralytics Python 包中的一项标准功能。

Link to this section在 Ultralytics YOLO 中设置学习率#

使用现代框架时,你可以轻松调整初始学习率 (lr0) 和最终学习率比例 (lrf)。以下是如何使用兼容 Ultralytics 平台 的客户端为自定义训练运行进行配置的示例。

from ultralytics import YOLO

# Load the YOLO26 model (latest state-of-the-art architecture)
model = YOLO("yolo26n.pt")

# Train the model with a custom initial learning rate
# lr0=0.01 sets the initial rate
# lrf=0.01 sets the final learning rate to (lr0 * lrf)
results = model.train(data="coco8.yaml", epochs=10, lr0=0.01, lrf=0.01)

对于高级用户,像 LR Finder(由 fast.ai 推广)这样的技术可以通过运行一个短期的试验轮次(在该轮次中学习率呈指数级增加直到损失发散)来自动发现最佳起始值。掌握此超参数通常是解锁你 AI 项目中 SOTA(最先进)性能的关键。

Explore solutions

Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多
Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多
Real-time AI that works with your team

机器人技术中的 AI

使用 Ultralytics YOLO 模型为智能机器赋能。机器人技术中的视觉 AI 可推动自主导航、感知、物体跟踪和实时控制。

了解更多
Real-time AI that works with your team

物流中的 AI

使用 Ultralytics YOLO 模型简化物流。视觉 AI 可实现包裹检查、分拣、车辆跟踪和实时仓库安全监控。

了解更多
Real-time AI that works with your team

零售业 AI

使用 Ultralytics YOLO 模型重塑零售业。视觉 AI 推动库存跟踪、货架监控、队列管理和更智能的客户洞察。

了解更多
Real-time AI that works with your team

医疗保健中的 AI

利用 Ultralytics YOLO 模型构建医疗保健解决方案。医疗保健中的视觉 AI 可助力更快速的医学影像分析、更智能的诊断和患者监测。

了解更多
Real-time AI that works with your team

制造业中的 AI

使用 Ultralytics YOLO 模型优化制造业。视觉 AI 推动质量控制、缺陷检测、PPE 合规性和装配线自动化。

了解更多
Real-time AI that works with your operation

汽车中的 AI

将计算机视觉应用于汽车行业,并配合 Ultralytics YOLO 模型。汽车视觉 AI 可提升道路安全、辅助驾驶和车辆自动化,打造更智能的道路。

了解更多
Real-time AI tailored to your operation

农业中的 AI

借助 Ultralytics YOLO 模型,将视觉 AI 引入智慧农业。赋能作物监测、牲畜追踪和精准农业,实现更高、更智能的产量。

了解更多

让我们一起构建 AI 的未来!

开启你的机器学习未来之旅