-2

Is there best practice / standard or automatic templates for YAML files for Machine Learning model configuration and architecture?

DISCLAIMER: the question is not related to YOLO models. The YOLO YAML is provided as an example/use case.

There are examples from YOLOv7 or v5 models, but question is not limited to YOLO models.

Here are some short example snippets, from the links below:

hyper parameters:

lr0: 0.01  # initial learning rate (SGD=1E-2, Adam=1E-3)
lrf: 0.1  # final OneCycleLR learning rate (lr0 * lrf)
momentum: 0.937  # SGD momentum/Adam beta1
weight_decay: 0.0005  # optimizer weight decay 5e-4
warmup_epochs: 3.0  # warmup epochs (fractions ok)
warmup_momentum: 0.8  # warmup initial momentum
warmup_bias_lr: 0.1  # warmup initial bias lr
box: 0.05  # box loss gain
cls: 0.3  # cls loss gain
cls_pw: 1.0  # cls BCELoss positive_we

model architecture:

nc: 80  # number of classes
depth_multiple: 1.0  # model depth multiple
width_multiple: 1.0  # layer channel multiple

# anchors
anchors:
  - [12,16, 19,36, 40,28]  # P3/8
  - [36,75, 76,55, 72,146]  # P4/16
  - [142,110, 192,243, 459,401]  # P5/32

# yolov7 backbone
backbone:
  # [from, number, module, args]
  [[-1, 1, Conv, [32, 3, 1]],  # 0
  
   [-1, 1, Conv, [64, 3, 2]],  # 1-P1/2      
   [-1, 1, Conv, [64, 3, 1]],
   
   [-1, 1, Conv, [128, 3, 2]],  # 3-P2/4  
   [-1, 1, Conv, [64, 1, 1]],
   [-2, 1, Conv, [64, 1, 1]],
   [-1, 1, Conv, [64, 3, 1]],

Example of model architecture for YOLOv7

Example of hyper parameters for YOLOv7

Michael D
  • 1,711
  • 4
  • 23
  • 38
  • Are you asking "how should I write a YAML file?" or are you asking "how should I design a YAML-based configuration interface for a new machine learning software that I wrote?" – Andrey Bienkowski Jun 06 '23 at 16:26
  • @AndreyBienkowski, I'm asking, if there is some standing or existing library which creates it. – Michael D Jun 07 '23 at 18:19

1 Answers1

1

There is no standard or automatic template for YAML files for Machine Learning model configurations and architectures. The structure and even the names for model weights varies from implementation to implementation. To use your YOLO example, one implementation might use the variable names and structure you gave in your question, other implementations such as mmYolo don't use YAML files at all.

Best practice is to copy the individual approach of the authors of the implementation you use. The given YAML files usually serve as a good template. That makes errors on your part less likely and helps with debugging. It also makes it easier for the author to understand what you're trying to do in case you reach out for help.

If you want to use YAML files for your own implementation, it helps to make YAML files as readable as possible to other users. You're pretty much free to do as you want when it comes to naming and structure. However, it helps to stick with naming convention already introduced, for example by the relevant YOLO paper which model you want to implement.

emely_pi
  • 517
  • 5
  • 23
  • Is there any best practice or some library or some which creates yaml templates ? – Michael D Jun 07 '23 at 18:21
  • This article published in Medium explains how to set up your own yaml template: https://medium.com/@woeterman_94/how-to-use-yaml-templates-63c6e79f6c3f – emely_pi Jun 08 '23 at 05:33