tensorflow / tensorflow/probability
Using DenseReparameterization inside symbolic loops
Nobody has claimed this yet.
- Dominant language
- Jupyter Notebook
- Stars
- 4.4k
- Forks
- 1.1k
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the problem is that the divergence is only built once, during the first layer.call(). This means if the layer was already used in one control flow context and is then applied again in another, the layer.losses will still contain the divergence tensor from the previous control flow context, which cannot be accessed from inside the new one.
My current workaround is to set layer._built_kernel_divergence = False before each invocation of the layer, and then add layer.losses[-1] to the loss function, which is the newly created divergence tensor.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with DenseReparameterization and its layer.call behavior, focusing on how _built_kernel_divergence and layer.losses behave across symbolic control-flow contexts. Reproduce the reported sequence of applying the layer in different contexts; done means each context exposes its own usable divergence tensor without the manual reset workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- tensorflow
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100