Skip to content
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

Custom optimizer #132

Merged
merged 21 commits into from
Nov 19, 2024
Merged

Custom optimizer #132

merged 21 commits into from
Nov 19, 2024

Conversation

JSabadin
Copy link
Contributor

@JSabadin JSabadin commented Nov 14, 2024

Custom SGD Optimizer Proposal

This PR introduces a custom implementation of the SGD optimizer with a unique step mechanism that is crucial for optimal performance.

Here is the YAML configuration file that yields the best results using this custom training strategy:

model:
  nodes:
    - name: EfficientRep
      params:
        variant: "n"
        download_weights: False

    - name: RepPANNeck
      params:
        download_weights: False
      inputs:
        - EfficientRep

    - name: EfficientBBoxHead
      params:
        download_weights: False
      inputs:
        - RepPANNeck

  losses:
    - name: AdaptiveDetectionLoss
      attached_to: EfficientBBoxHead
      params:
        iou_type: "siou"
        n_warmup_epochs: 0
        iou_loss_weight: 20 # Should be 2.5 * accumulate_grad_batches
        class_loss_weight: 8 # Should be 1 * accumulate_grad_batches
        

  metrics:
    - name: MeanAveragePrecision
      is_main_metric: true
      attached_to: EfficientBBoxHead

  visualizers:
    - name: BBoxVisualizer
      attached_to: EfficientBBoxHead


loader:
  name: LuxonisLoaderTorch

  train_view: train
  val_view: train
  test_view: train

  params:
    dataset_name: cow_finetune
    bucket_storage: "local"

trainer:
  seed: 42
  precision: "16-mixed"
  preprocessing:
    train_image_size: [640, 640]
    keep_aspect_ratio: true
    normalize:
      active: true
      params:
        mean: [0., 0., 0.]
        std: [1, 1, 1]

  skip_last_batch: False
  batch_size: 8
  accumulate_grad_batches: 8
  epochs: &epochs 80
  num_workers: 4
  validation_interval: 10
  num_log_images: 8
  n_sanity_val_steps: 0

  training_strategy:
    name: "TripleLRSGDStrategy"
    params: 
      warmup_epochs: 3
      warmup_bias_lr: 0.1
      warmup_momentum: 0.8
      lr: 0.02
      lre: 0.0002
      momentum: 0.937     
      weight_decay: 0.0005     
      nesterov: True


  callbacks:
    - name: EMACallback
      params:
        decay: 0.9999 
        use_dynamic_decay: True 
        decay_tau: 2000
    

@JSabadin JSabadin requested a review from a team as a code owner November 14, 2024 12:45
@JSabadin JSabadin requested review from kozlov721, klemen1999, tersekmatija and conorsim and removed request for a team November 14, 2024 12:45
@github-actions github-actions bot added the enhancement New feature or request label Nov 14, 2024
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 15, 2024
Copy link

codecov bot commented Nov 15, 2024

Codecov Report

Attention: Patch coverage is 64.93506% with 54 lines in your changes missing coverage. Please review.

Project coverage is 95.16%. Comparing base (631b905) to head (2951676).
Report is 16 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
luxonis_train/strategies/triple_lr_sgd.py 30.15% 44 Missing ⚠️
luxonis_train/models/luxonis_lightning.py 50.00% 6 Missing ⚠️
luxonis_train/callbacks/training_manager.py 62.50% 3 Missing ⚠️
luxonis_train/strategies/base_strategy.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
- Coverage   96.31%   95.16%   -1.16%     
==========================================
  Files         147      164      +17     
  Lines        6304     7160     +856     
==========================================
+ Hits         6072     6814     +742     
- Misses        232      346     +114     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

configs/README.md Show resolved Hide resolved
luxonis_train/models/luxonis_lightning.py Outdated Show resolved Hide resolved
luxonis_train/strategies/base_strategy.py Show resolved Hide resolved
@klemen1999 klemen1999 merged commit 23e8704 into main Nov 19, 2024
7 of 9 checks passed
@klemen1999 klemen1999 deleted the feat/yolov6n-optimizer-weight-init branch November 19, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants