AlbinSou / ocl_survey

Code for "A Comprehensive Empirical Evaluation on Online Continual Learning" ICCVW 2023 VCL Workshop
https://arxiv.org/abs/2308.10328
MIT License
31 stars 9 forks source link

TypeError: BaseSGDTemplate.__init__() missing 2 required positional arguments: 'model' and 'optimizer' #5

Closed hiteshvaidya closed 9 months ago

hiteshvaidya commented 9 months ago

I am trying to run this code and get the above mentioned error.

My shell script looks like this,

cd /data/hvaidya/ocl_survey/experiments
HYDRA_FULL_ERROR=1 python main.py strategy=er_ace experiment=split_cifar100 strategy.train_epochs=1

I changed the default dataset_root in default.yaml in deploy folder because there is no /DATA folder therefore that throws an error. But it got resolved after I mentioned custom dataset root.

benchmark:
  dataset_root: /data/hvaidya/ #/DATA/data

When I run the shell script, I get the following error.

/data/hvaidya/ocl_survey/experiments/main.py:20: UserWarning: 
The version_base parameter is not specified.
Please specify a compatability version level, or None.
Will assume defaults for version 1.1
  @hydra.main(config_path="../config", config_name="config.yaml")
/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/hydra.py:119: UserWarning: Future Hydra versions will no longer change working directory at job runtime by default.
See https://hydra.cc/docs/1.2/upgrades/1.1_to_1.2/changes_to_job_working_dir/ for more information.
  ret = run_job(
Files already downloaded and verified
Files already downloaded and verified
[44, 19, 93, 90, 71, 69, 37, 95, 53, 91, 81, 42, 80, 85, 74, 56, 76, 63, 82, 40, 26, 92, 57, 10, 16, 66, 89, 41, 97, 8, 31, 24, 35, 30, 65, 7, 98, 23, 20, 29, 78, 61, 94, 15, 4, 52, 59, 5, 54, 46, 3, 28, 2, 70, 6, 60, 49, 68, 55, 72, 79, 77, 45, 1, 32, 34, 11, 0, 22, 12, 87, 50, 25, 47, 36, 96, 9, 83, 62, 84, 18, 17, 75, 67, 13, 48, 39, 21, 64, 88, 38, 27, 14, 73, 33, 58, 86, 43, 99, 51]
SGD (
Parameter Group 0
    dampening: 0
    differentiable: False
    foreach: None
    lr: 0.1
    maximize: False
    momentum: 0.0
    nesterov: False
    weight_decay: 0.0
)
Error executing job with overrides: ['strategy=er_ace', 'experiment=split_cifar100', 'strategy.train_epochs=1']
Traceback (most recent call last):
  File "/data/hvaidya/ocl_survey/experiments/main.py", line 126, in <module>
    main()
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/main.py", line 94, in decorated_main
    _run_hydra(
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/utils.py", line 394, in _run_hydra
    _run_app(
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/utils.py", line 457, in _run_app
    run_and_report(
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/utils.py", line 223, in run_and_report
    raise ex
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/utils.py", line 220, in run_and_report
    return func()
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/utils.py", line 458, in <lambda>
    lambda: hydra.run(
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/_internal/hydra.py", line 132, in run
    _ = ret.return_value
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/core/utils.py", line 260, in return_value
    raise self._return_value
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/hydra/core/utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
  File "/data/hvaidya/ocl_survey/experiments/main.py", line 81, in main
    strategy = method_factory.create_strategy(
  File "/data/hvaidya/ocl_survey/src/factories/method_factory.py", line 295, in create_strategy
    cl_strategy = globals()[strategy](**strategy_dict, plugins=plugins)
  File "/data/hvaidya/ocl_survey/src/strategies/erace.py", line 108, in __init__
    super().__init__(
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/avalanche/training/templates/common_templates.py", line 122, in __init__
    super().__init__()  # type: ignore
  File "/home/h/hvaidya/.conda/envs/ocl_survey/lib/python3.10/site-packages/avalanche/training/templates/observation_type/batch_observation.py", line 16, in __init__
    super().__init__()
TypeError: BaseSGDTemplate.__init__() missing 2 required positional arguments: 'model' and 'optimizer'

Could you please help me resolve this?

hiteshvaidya commented 9 months ago

Upon looking further into it I found that the error is caused because the model and optimizer variables are set to null by default in config.yaml. Is there anything we can do to set those parameters?

AlbinSou commented 9 months ago

Hello,

Thanks for the issue.

Sure, this is an error that I have already encountered with the avalanche library but I thought it was fixed. The problem comes from the library typing-extensions. Avalanche requires that this library is in version 4.4, for some reason during the installation of the libraries pip decided to install a newer version of this library than the one required by avalanche. Maybe this is due to the order of the installation, I have to check that.

In the meantime, all you have to do to fix it should be

pip install typing-extensions==4.4.0

Let me know if this solves the problem.

hiteshvaidya commented 9 months ago

that worked for me. thanks! for your prompt reply

AntonioCarta commented 9 months ago

@AlbinSou is this repo using the Avalanche 0.4 version? the old commits may not have the typing-extensions==4.4.0 requirement.

AlbinSou commented 9 months ago

I just checked, it is using a version just before 0.4.0. And yes, it did not have the update to requirements file. Maybe I will try to make it use 0.4.0 that way I can switch the installation to pip install avalanche-lib.