[Python] Comparing the Weights and Biases of several different Yolov8s models trained through...

Discussão em 'Python' iniciado por Stack, Fevereiro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I have 3 different yolov8s models which I would like to assess:


    1. Yolov8s trained with the normal model.train() command


    2. Yolo8vs model trained with a frozen backbone


    3. Yolov8s model trained with all layers frozen

    I am using a callback function to freeze the weights, see below:

    def freeze_layer(trainer):
    model = trainer.model
    num_freeze = 10
    print(f"Freezing {num_freeze} layers")
    freeze = [f'model.{x}.' for x in range(num_freeze)] # layers to freeze
    for k, v in model.named_parameters():
    v.requires_grad = True # train all layers
    if any(x in k for x in freeze):
    print(f'freezing {k}')
    v.requires_grad = False
    print(f"{num_freeze} layers are freezed.")

    if __name__ == "__main__":
    model = YOLO(yolov8s.pt)
    model.add_callback("on_train_start", freeze_layer)
    model.train(
    data="coco128.yaml",
    epochs=300,
    imgsz=640
    )


    I want to be able to assess the differences in the weights and biases between these 3 neural networks. I want to see which neurons are dead after transfer learning and assess the major differences between all three neural networks. Are there any standard solutions to use to gain this kind of insight into a neural network?

    I have compared the standard training metrics that yolo provides like MAP and Loss and everything is as expected. The more layers you freeze the worse performce gets. And when I freeze the whole network the performance is much worse than the other 2 instances.

    I barely know where to begin when it comes to comparing the same network architetchure but just trained differently.

    Any help is much appreciated.

    Continue reading...

Compartilhe esta Página