Inspect any ONNX model in your browser

YOLO Hyperparameters Explained: Visual Training Guide

Learn how 18 Ultralytics YOLO training hyperparameters, including learning rate, batch size, epochs, image size, augmentation, and loss weights, affect model training. Explore beginner-friendly explanations, real-world analogies, and animated examples to understand how to tune YOLO for better object detection performance.

01 · Optimization

Initial learning rate (lr0)

How big should each learning step be?

What it means

Controls the initial size of optimizer updates. A tiny learning rate learns slowly. An oversized one can make training bounce around instead of improving.

A simple way to think about it

Imagine learning to throw a ball into a basket. If you change your aim by a huge amount after every miss, you may keep overshooting. If you adjust it just a little, you can get closer steadily. Learning rate controls the size of those adjustments.

Lower values

Very slow learning or underfitting.

Higher values

Unstable updates, oscillation or divergence.

Practical tip: Start from the optimizer's recommended settings; reduce when loss oscillates.

Look for unstable training loss and validation mAP that stops improving.

Finding the right step size
× FalseLess helpful
Large adjustment overshoots
✓ TrueHelpful example
Small adjustment hits target

Like approaching a target: smaller, careful steps can avoid overshooting.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

02 · Optimization

Final LR factor (lrf)

How gently should learning finish?

What it means

Multiplier for the final scheduled learning rate relative to lr0. This controls how much the learning rate shrinks near the end, helping the model make smaller finishing adjustments.

A simple way to think about it

Imagine riding a bicycle toward a parking spot. You move faster at first, then slow down to park carefully. The final learning-rate factor helps decide how small the model's adjustments become near the end.

Lower values

Very small end-of-training updates.

Higher values

Larger updates persist near the end.

Practical tip: Final scheduled LR is approximately lr0 × lrf; the schedule and warmup matter.

Compare late-epoch validation mAP and whether training settles.

Slowing down before the finish
× FalseLess helpful
Cyclist rushes past finish
✓ TrueHelpful example
Cyclist slows before finish

Like cycling toward a finish line: slow down when precision matters.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

03 · Optimization

Batch size

How many images does the model see per update?

What it means

Number of images used per optimization batch; memory use grows with batch size. Small batches can make updates noisy; larger ones use more GPU memory and change optimization behavior.

A simple way to think about it

Imagine a teacher checking homework. Instead of changing the lesson after every single student's answer, the teacher looks at a group of answers first. Batch size is how many images the model learns from before one update.

Lower values

Noisier gradients and potentially slower throughput.

Higher values

Smoother gradients but more GPU memory; generalization may change.

Practical tip: Choose what fits memory and compare at equivalent training budgets.

Watch loss smoothness, training speed and validation performance.

Carrying groceries in groups
× FalseLess helpful
Too many items at once
✓ TrueHelpful example
Manageable grocery load

A batch is like the number of grocery bags you carry in one trip.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

04 · Training

Epochs

How long should training continue?

What it means

Maximum passes through the training dataset. Too few epochs can leave the model unfinished; too many may waste compute or overfit.

A simple way to think about it

Imagine revising the same textbook for an exam. Reading it once may not be enough; revising it several times can help. But reading it 100 more times does not automatically improve your exam score. Each full pass through the training data is an epoch.

Lower values

May stop before convergence.

Higher values

More compute; potential overfitting without validation monitoring.

Practical tip: Watch validation mAP and loss rather than assuming more epochs is better.

Watch whether validation mAP levels off while training loss keeps falling.

Practicing a skill again
× FalseLess helpful
Too little practice
✓ TrueHelpful example
Practice improves the result

Repeating practice helps you improve, but endless repetition is not always useful.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

05 · Training

Image size

How much image detail can the model see?

What it means

Input resolution for training. Larger images may help with tiny objects, but require more memory and computation.

A simple way to think about it

Imagine looking at a photo on a tiny phone screen versus zooming into a large monitor. A distant traffic sign may be easier to see in the larger version, but the bigger image takes more work to process.

Lower values

Faster and cheaper; small objects may lose detail.

Higher values

Small-object detail may improve at higher compute and memory cost.

Practical tip: Evaluate at the resolution and latency relevant to deployment.

Compare small-object AP, mAP and inference speed.

Looking at a picture closely
× FalseLess helpful
Tiny details are missed
✓ TrueHelpful example
Enough detail to spot an insect

A clearer, larger picture makes tiny details easier to notice.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

06 · Regularization

Weight decay

How strongly should the model avoid overly complex weights?

What it means

Penalizes large weights to help regularize training. A little regularization can help generalization; too much can stop the model learning enough.

A simple way to think about it

Imagine writing an essay. Adding complicated words everywhere might make it harder to understand. A teacher encourages simpler writing unless the extra detail is useful. Weight decay similarly discourages unnecessarily large model weights.

Lower values

Less regularization; possible overfitting.

Higher values

Too much regularization may underfit.

Practical tip: Compare train-versus-validation gaps on the same split.

Compare training and validation loss for overfitting or underfitting.

Packing just what you need
× FalseLess helpful
Overpacked with extra details
✓ TrueHelpful example
Pack only what is useful

Keeping things simple can help avoid memorizing unnecessary details.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

07 · Optimization

Momentum

How much should previous updates influence the next one?

What it means

Smooths optimizer updates; behavior depends on the optimizer. Momentum smooths noisy updates, but excessive momentum can make training overshoot.

A simple way to think about it

Imagine pushing a shopping cart. Once it starts moving forward, it does not instantly change direction with every tiny push. Momentum helps training keep a steadier direction instead of reacting strongly to every noisy update.

Lower values

Updates respond quickly but may be noisy.

Higher values

More smoothing; can overshoot if poorly tuned.

Practical tip: Change with care; optimizer-specific defaults are a better baseline.

Watch loss oscillation and how quickly validation metrics settle.

Pushing a shopping cart
× FalseLess helpful
Cart changes direction wildly
✓ TrueHelpful example
Cart rolls steadily forward

A rolling cart keeps some of its direction between pushes.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

08 · Optimization

Warmup epochs

Should the model start slowly?

What it means

Gradually ramps optimization settings early in training. Warmup eases into full training updates and can prevent unstable early learning.

A simple way to think about it

Imagine warming up before a race. Sprinting at full speed immediately may be difficult; starting gently helps you get going. Warmup lets the model begin with smaller training updates before reaching its normal learning rate.

Lower values

Full updates arrive sooner, potentially unstable.

Higher values

More conservative startup, but less time at the main schedule.

Practical tip: Useful when early loss spikes or fine-tuning is unstable.

Watch the first epochs for spikes in loss.

Warming up before a run
× FalseLess helpful
Sprint at full speed immediately
✓ TrueHelpful example
Walk, then gradually run

A gentle start helps before working at full speed.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

09 · Augmentation

Mosaic augmentation

Should the model learn from combined scenes?

What it means

Probability of combining four images into a mosaic. Mosaic mixes four training images to show more scales and contexts, but can look unlike real scenes.

A simple way to think about it

Imagine cutting four different photos into pieces and arranging them on one poster. The model learns to recognize objects in unusual combinations and sizes. The poster is useful practice, even though it is not a real photograph.

Lower values

More natural training images.

Higher values

More context and scale diversity, sometimes unrealistic composites.

Practical tip: Test against realistic validation images, especially for small objects.

Check validation mAP and small-object performance on natural images.

Making a photo collage
× FalseLess helpful
Only one familiar scene
✓ TrueHelpful example
Combine varied photo scenes

A collage teaches you to recognize things in unusual surroundings.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

10 · Augmentation

MixUp augmentation

Should the model learn from blended images?

What it means

Probability of blending training images and labels. MixUp blends training examples to encourage robustness, but too much can hide useful visual detail.

A simple way to think about it

Imagine placing a transparent photo of a cat over a photo of a dog. You can partly see both. MixUp gives the model blended training examples, which can help robustness, but too much blending can make objects hard to recognize.

Lower values

No MixUp blending.

Higher values

Strong regularization; can obscure objects and hurt fit.

Practical tip: Increase cautiously on datasets where blended scenes remain useful.

Compare validation AP and missed detections.

Mixing two paint colors
× FalseLess helpful
No variation in examples
✓ TrueHelpful example
Blend examples gently

Blending examples helps the model learn beyond a single familiar view.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

11 · Augmentation

Close mosaic (epochs)

When should mosaic augmentation stop?

What it means

Disables mosaic in the final N epochs, when enabled. Switching mosaic off near the end lets the model finish training on more natural-looking images.

A simple way to think about it

Imagine practicing football with unusual training drills, then playing normal matches just before a tournament. Closing mosaic means the model stops seeing four-photo combinations near the end and finishes with more natural images.

Lower values

Mosaic continues closer to the end.

Higher values

More late-stage training on natural images.

Practical tip: Useful for settling final localization after aggressive augmentation.

Look for more stable late-stage validation localization.

Practicing for the real game
× FalseLess helpful
Keep artificial collage to the end
✓ TrueHelpful example
Finish on realistic photos

After unusual practice exercises, finish with realistic examples.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

12 · Training

Early stopping patience

How long should training wait for progress?

What it means

Epochs without fitness improvement before early stopping. Early stopping avoids wasting epochs, but stopping too soon can miss a later improvement.

A simple way to think about it

Imagine solving practice questions and tracking your scores. If your score has not improved for many practice rounds, you might stop rather than repeat the same exercise forever. Patience sets how long training waits for a new validation improvement.

Lower values

Stops sooner, may miss later improvements.

Higher values

Waits longer; uses more compute.

Practical tip: Set based on validation noise and available training time.

Inspect best validation fitness and the epoch where training stops.

Waiting for progress
× FalseLess helpful
Stop before progress appears
✓ TrueHelpful example
Wait to see real improvement

Wait long enough for progress, but stop when nothing improves.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

13 · Loss

Box loss gain

How much should accurate box placement matter?

What it means

Relative weight of bounding-box regression loss. This weight tells training to pay more attention to box locations, relative to other losses.

A simple way to think about it

Imagine drawing a rectangle around a car in a photo. The box should fit the car closely, not include half the road. Increasing box-loss weight tells training to pay more attention to making those rectangles accurate.

Lower values

Less emphasis on localization.

Higher values

More localization emphasis, potentially at expense of classification.

Practical tip: Compare localization error and AP across IoU thresholds.

Inspect localization quality and mAP at stricter IoU thresholds.

Framing a picture
× FalseLess helpful
Loose frame misses boundaries
✓ TrueHelpful example
Tight frame around the object

Paying attention to the frame helps it fit the object.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

14 · Loss

Classification loss gain

How much should class labels matter?

What it means

Relative weight of class prediction loss. This weight changes the emphasis on predicting the correct category.

A simple way to think about it

Imagine sorting pictures into folders labeled cat, dog, and bicycle. The model must choose the correct folder for each object. Classification-loss weight changes how strongly training focuses on getting those labels right.

Lower values

Less emphasis on distinguishing classes.

Higher values

More class emphasis, which may shift the loss balance.

Practical tip: Inspect per-class AP and confusion matrix before adjusting.

Check per-class AP and the confusion matrix.

Sorting items into baskets
× FalseLess helpful
CarApple labeled as a car
✓ TrueHelpful example
AppleApple goes into apple basket

Recognizing what something is matters as much as spotting it.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

15 · Loss

DFL loss gain

How much should fine-grained box boundaries matter?

What it means

Weight for distribution-based box localization loss where supported. For models using distribution focal loss, this adjusts emphasis on precise box boundaries.

A simple way to think about it

Imagine drawing a rectangle around a person, then carefully adjusting its left, right, top, and bottom edges. Distribution focal loss helps a compatible detector learn where those boundaries should be.

Lower values

Less emphasis on box distribution refinement.

Higher values

More emphasis on distributional localization.

Practical tip: Check the selected model/task actually uses DFL before tuning.

Compare stricter-IoU AP and box quality; not every model uses DFL.

Fine-tuning a picture frame
× FalseLess helpful
Edges remain slightly off
✓ TrueHelpful example
Edges aligned precisely

Small adjustments can make the edges of a frame more accurate.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

16 · Optimization

Cosine learning-rate schedule

Should the learning rate follow a smooth curve?

What it means

Switches the learning-rate decay schedule to a cosine curve. Use 0 for off or 1 for on; the shape of the schedule affects how quickly update sizes shrink. A cosine schedule gradually changes the optimizer step size over training. It can provide a gentler finish, but it is not automatically better for every dataset.

A simple way to think about it

Imagine slowing a bicycle smoothly as you approach a stop. A cosine learning-rate schedule changes your training step size along a curved path instead of a simple straight decline.

Lower values

The default learning-rate decay strategy is used.

Higher values

Cosine decay smoothly changes the learning rate across training.

Practical tip: Compare learning curves using the same lr0, lrf, training duration, and optimizer.

Compare validation mAP and learning curves against the standard schedule.

Slowing smoothly near a finish
× FalseLess helpful
Abrupt straight slowdown
✓ TrueHelpful example
Smooth curved slowdown

A smooth learning-rate curve changes training step sizes gradually.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

17 · Augmentation

Horizontal flip probability

Should training images sometimes be mirrored?

What it means

Probability of flipping a training image left to right, teaching the detector to recognize objects from mirrored views. Horizontal flipping gives the model left-to-right variations of familiar objects. This helps when orientation does not change the label, but can be wrong for directional signs or text.

A simple way to think about it

Imagine looking at a car from the opposite side of the road. A mirrored photo can help you recognize the car, but mirroring a word or one-way sign could change its meaning.

Lower values

Fewer mirrored training examples.

Higher values

More mirrored examples, which can be harmful if left versus right carries meaning.

Practical tip: Avoid or reduce horizontal flipping for directional text, signs, and left/right-sensitive tasks.

Check performance on real left/right orientations and direction-sensitive classes.

Seeing an object in a mirror
× FalseLess helpful
Mirror direction-sensitive text
✓ TrueHelpful example
Mirror a shape safely

A mirror image can be useful practice, but not when direction changes meaning.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

18 · Augmentation

Hue augmentation strength

How much should training colors change?

What it means

Controls random shifts in image hue during training, helping the model handle changes in color and lighting. Small hue changes can help an object detector cope with lighting and camera differences. Large changes may make color-dependent objects unrealistic.

A simple way to think about it

Imagine taking a photo of the same flower in morning and evening light. Its colors look a little different, but it is still the same flower. Hue augmentation gives training images controlled color variation.

Lower values

Colors stay closer to the original images.

Higher values

Greater color variation; too much may distort important class-specific colors.

Practical tip: Use small changes and validate carefully when object color is important.

Check performance under different lighting and inspect augmented examples.

Recognizing colors under different light
× FalseLess helpful
Extreme unrealistic color shifts
✓ TrueHelpful example
Natural lighting variation

Gentle color variation helps with changing light without losing the object.

Illustrative animation, not a measured model result. The best setting depends on your dataset and task.

A practical tuning workflow

Step 1

Start with a baseline

Keep a fixed train/validation split and record model weights, seed, data version, optimizer and image size. Train once before tuning.

Step 2

Check the learning curves

Compare training loss and validation mAP@0.50:0.95. Unstable loss suggests investigating the learning rate; a widening train–validation gap may indicate overfitting.

Step 3

Change one family at a time

Tune learning rate and schedule first, then batch/image size, then augmentation and regularization. Compare multiple seeds when differences are small.

Step 4

Evaluate the right metrics

Review per-class AP, confusion matrix, precision–recall curves, small-object behavior and deployment latency, not only a single mAP value.

Train a baseline in Python

This example uses the Ultralytics Python API. Choose weights supported by your installed version and task. Compare each experiment against the same validation split.

from ultralytics import YOLO

# Load a pretrained YOLO26 detection model.
model = YOLO("yolo26n.pt")

# Train on your dataset with a reproducible baseline.
model.train(
    data="data.yaml",
    epochs=100,
    imgsz=640,
    batch=16,
    lr0=0.01,
    lrf=0.01,
    patience=30,
    seed=42,
)

# Evaluate the trained model on the validation split.
metrics = model.val(data="data.yaml")
print(f"mAP50-95: {metrics.box.map:.4f}")

Keep validation preprocessing and confidence/IoU evaluation settings consistent. For reproducibility, also record package version, hardware, split and augmentation settings.

Frequently asked questions

Does a higher learning rate increase mAP?

Not necessarily. An excessive rate can destabilize training, while a rate that is too small can prevent convergence within the available epochs.

Why does precision increase when recall decreases?

Raising the inference confidence threshold often filters false positives but also removes some true detections. This is different from changing training hyperparameters.

Is mAP@0.50 the same as mAP@0.50:0.95?

No. mAP@0.50 uses one IoU threshold; mAP@0.50:0.95 averages AP over ten thresholds from 0.50 through 0.95 and is stricter about localization.

Which hyperparameters should I tune first?

Start with learning rate, training duration, image size and batch size, while checking data quality. Augmentation and loss weighting come after a reproducible baseline.

For more information, visit the Ultralytics training documentation and configuration reference.