`with ComputationGraph():` syntax?
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 701
- PR merge metrics
- No merged PRs in 30d
Description
From my own experience with new dynet (python) users, one of the most common mistakes is forgetting to renew the computation graph (in particular at test time where it sometimes doesn't run out of memory but becomes super slow).
What do you think of adding something like:
```python
with ComputationGraph():
# do stuff within one computation graph
# Every expression here is stale
```
I don't think it would be more work and it could easily be made backward compatible by keeping `renew_cg` and just rewriting the docs to promote the new preffered syntax.
Thoughts?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the Python ComputationGraph API and the existing renew_cg behavior referenced in the issue. Determine the context-manager design, preserve backward compatibility, and update the relevant documentation; done means the proposal is implemented and the documented syntax renews graphs as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100