Dynamic update of pytorch config with dot notation by maximpavliv · Pull Request #2859 · DeepLabCut/DeepLabCut

Conversation

@maximpavliv

In this Pull Request, in order to facilitate the dynamic update of pytorch_config.yaml (when calling deeplabcut.train_network()), I:

  • Implement the update_config_by_dotpath() method. This method is easier to use than the previous update_config(). With update_config(), you needed to pass a nested dictionary as argument to target nested arguments in the pytorch_config.yaml, and it wasn't explicit how the nested dict was processed. With update_config_by_dotpath(), you target nested arguments by using a single-level dictionary with dot-notation path access. For example to update the gpus list in the runner section, you pass {"runner.gpus": [0,1]} (instead of dict(runner=dict(gpus=[0,1])))
  • Pass updates to the pytorch configuration with the pytorch_cfg_updates: dict argument instead of using the kwargs in train_network().
  • Make explicit all the other arguments that can be passed to train_network() (that were passed through the kwargs before) for more transparency, and remove the kwargs argument from train_network().
  • Implement a test for the new update_config_by_dotpath() method, update integration tests.

n-poulsen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor change needed - otherwise looks good to me!

n-poulsen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples/utils.py file also needs to be updated; currently both the testscript_pytorch_single_animal.py and the testscript_pytorch_multi_animal.py fail

@maximpavliv

The examples/utils.py file also needs to be updated; currently both the testscript_pytorch_single_animal.py and the testscript_pytorch_multi_animal.py fail

You're right, now I solved this!

n-poulsen

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n-poulsen n-poulsen deleted the maxim/update_config_by_dotpath branch

February 5, 2025 13:14

Labels

2 participants

@maximpavliv @n-poulsen