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

Add a variable to control whether to retain the graph or not in the backward pass #1388

Merged
merged 1 commit into from May 29, 2023

Conversation

BenCrulis
Copy link

With the addition of this variable, you can decide to keep the graph by setting strategy.retain_graph = True so that plugins can do their own backward pass after to the one triggered automatically without having to execute the forward pass again.

Unsatisfactory alternatives:

  • subclass BaseSGDTemplate and change the implementation of its backward() method
  • monkey patch the backward() method
  • call strategy.forward() each time a second backward pass has to be made in the same iteration

Note that perhaps the name of this variable should be changed to something else.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5079535595

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • 32 unchanged lines in 10 files lost coverage.
  • Overall coverage increased (+0.1%) to 72.249%

Files with Coverage Reduction New Missed Lines %
avalanche/benchmarks/datasets/clear/clear.py 1 13.02%
avalanche/benchmarks/scenarios/benchmark_wrapper_utils.py 1 73.33%
tests/training/test_supervised_regression.py 1 79.12%
avalanche/benchmarks/datasets/downloadable_dataset.py 2 30.61%
avalanche/evaluation/metrics/amca.py 2 75.36%
avalanche/evaluation/metrics/gpu_usage.py 2 38.33%
avalanche/evaluation/metrics/forgetting_bwt.py 3 49.36%
avalanche/evaluation/metrics/forward_transfer.py 4 49.18%
avalanche/evaluation/metric_definitions.py 7 75.46%
avalanche/benchmarks/datasets/mini_imagenet/mini_imagenet.py 9 17.19%
Totals Coverage Status
Change from base Build 5065785914: 0.1%
Covered Lines: 15845
Relevant Lines: 21931

💛 - Coveralls

@AntonioCarta
Copy link
Collaborator

Thanks. I didn't consider the fact that plugin may need to set retain_graph, which makes subclassing useless. I think your solution is ok.

@AntonioCarta AntonioCarta merged commit 647c154 into ContinualAI:master May 29, 2023
15 checks passed
@BenCrulis BenCrulis deleted the retain_graph branch May 29, 2023 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants