Thinklab-SJTU / ThinkMatch

A research protocol for deep graph matching.
https://thinkmatch.readthedocs.io/
Other
835 stars 118 forks source link

cfg with Ray Tune #33

Closed nurlanov-zh closed 2 years ago

nurlanov-zh commented 3 years ago

It seems that when using Ray Tune for hyperparameter optimization it does not properly load the .yaml file in cfg:

def cfg_from_file(filename):
    """Load a config file and merge it into the default options."""
    import yaml
    with open(filename, 'r') as f:
        yaml_cfg = edict(yaml.full_load(f))

    if 'MODULE' in yaml_cfg and yaml_cfg.MODULE not in __C:
        model_cfg_module = '.'.join(yaml_cfg.MODULE.split('.')[:-1] + ['model_config'])
        mod = importlib.import_module(model_cfg_module)
        __C.update(mod.model_cfg)

    if 'DATASET_FULL_NAME' in yaml_cfg and yaml_cfg.DATASET_FULL_NAME not in __C:
        __C[yaml_cfg.DATASET_FULL_NAME] = src.dataset.dataset_cfg[yaml_cfg.DATASET_FULL_NAME]

    _merge_a_into_b(yaml_cfg, __C)
2021-11-17 10:06:22,932 ERROR trial_runner.py:924 -- Trial train_ray_tune_9e7c5_00000: Error processing event.
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/ray/tune/trial_runner.py", line 890, in _process_trial
    results = self.trial_executor.fetch_result(trial)
  ...
  File "/root/.local/lib/python3.7/site-packages/ray/tune/utils/trainable.py", line 344, in inner
    trainable(config, **fn_kwargs)
  File "train_eval.py", line 360, in train_ray_tune
    model = Net()
  File "/workspace/models/GANN/model.py", line 25, in __init__
    self.affinity_layer = AffinityInp(cfg.GANN.FEATURE_CHANNEL)
AttributeError: 'EasyDict' object has no attribute 'GANN'

also:

...
AttributeError: 'EasyDict' object has no attribute 'PascalVOC'