-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to train a model after carrying out hyperparameter tuning? #12805
Comments
do you mean using previous hyperparameters on new training? |
@Kayzwer hello! To train your model using the new hyperparameters you've tuned, you simply need to integrate those hyperparameters into your training session. Here’s how you can start training your model with the adjusted parameters: from ultralytics import YOLO
# Load a model
model = YOLO("yolov8n.pt")
# Train the model with the tuned hyperparameters
results = model.train(data="coco8.yaml", epochs=30, optimizer="AdamW") Make sure to adjust the |
Sorry, but I don't seem to understand how the code you provided is training the model with the tuned parameters. Do you mean that when loading the model, I should use the weights I got after hyperparameter tuning like this? : model = YOLO("/content/runs/detect/tune/weights/last.pt") And then train the model like this? : model.train(data = 'config.yaml', epochs =100, imgsz = 640) Or the training has to something with the best_hyperparameters.yaml file provided after hyperparameter tuning? Please guide me on this. Thanks. |
@Habib0905 there is no way to load config like that, so sad you need to type it all out, or maybe you can make a pull request for this feature. |
@Habib0905 @Kayzwer yes you can load a custom config YAML like this instead of using default.yaml: model.train(cfg = "path/to/custom/config.yaml") This config.yaml should be a copy of default.yaml with any changes you want. |
Could you please clear my confusion about this? |
Hello! Absolutely, I can help clarify this for you. 🌟 After hyperparameter tuning, you should indeed use the from ultralytics import YOLO
# Load the model with the best weights from tuning
model = YOLO("/content/runs/detect/tune/weights/best.pt")
# Train the model using the optimized hyperparameters
model.train(data='config.yaml', cfg='path/to/best_hyperparameters.yaml', epochs=100, imgsz=640) Here, |
Search before asking
Question
I have carried out hyperparameter tuning on a yolo pose estimation model. I have used this:
from ultralytics import YOLO
Initialize the YOLO model
model = YOLO("yolov8n.pt")
Tune hyperparameters on COCO8 for 30 epochs
model.tune(data="coco8.yaml", epochs=30, iterations=300, optimizer="AdamW", plots=False, save=False, val=False)
But now with these new hyperparameters I want to train a model. Could you please provide details on how to do it.
Additional
No response
The text was updated successfully, but these errors were encountered: