Skip to content

Conversation

markusschmaus
Copy link
Contributor

@markusschmaus markusschmaus commented Sep 15, 2022

Recreation of #6096 after failing test (fixed in latest commit).

Introduces the start_sigma argument which allows to set a starting value for the sigmas of mean field approximation in ADVI. I am using the ordering property to create the mapping between the variables and the flat 1d array required by ADVI.

See also:
https://discourse.pymc.io/t/quality-of-life-improvements-to-advi/10254

Checklist

Major / Breaking Changes

  • None

Bugfixes / New features

  • Allow start_sigma being given to fit.
  • For ASVGD forward the key word arguments start and random_seed to the constructor of the default approximation FullRank instead of sending them to super().__init__ which can't process them
  • Enable _iterate_with_loss to run with n=0 by giving an appropriate logger message. This allows to check initialization values, which is useful for testing, but could also be useful for debugging a user model

Docs / Maintenance

  • The documentation for the start argument was outdated, it claimed type Point, but it gets passed through to a function that requires StartDict. Since users are probably unfamiliar with this custom type (Dict[Union[Variable, str], Union[np.ndarray, Variable, str]]), I decided to also mention the most relevant and most commonly used subtype dict[str, np.ndarray].

@markusschmaus markusschmaus mentioned this pull request Sep 15, 2022
5 tasks
@markusschmaus markusschmaus marked this pull request as ready for review September 15, 2022 14:18
@markusschmaus markusschmaus changed the title Advi start sigma2 Add start_sigma to ADVI 2 Sep 15, 2022
@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #6132 (762a6ca) into main (2b39a0c) will decrease coverage by 8.65%.
The diff coverage is 81.25%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6132      +/-   ##
==========================================
- Coverage   92.91%   84.25%   -8.66%     
==========================================
  Files         101      101              
  Lines       20929    20941      +12     
==========================================
- Hits        19446    17644    -1802     
- Misses       1483     3297    +1814     
Impacted Files Coverage Δ
pymc/variational/inference.py 84.97% <57.14%> (-1.13%) ⬇️
pymc/variational/approximations.py 87.67% <100.00%> (+0.34%) ⬆️
pymc/tests/tuning/test_scaling.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/tuning/test_starting.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_bound.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_censored.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_transform.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_truncated.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/distributions/test_simulator.py 0.00% <0.00%> (-99.51%) ⬇️
pymc/tests/distributions/test_dist_math.py 0.00% <0.00%> (-99.26%) ⬇️
... and 16 more

Copy link
Member

@junpenglao junpenglao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@junpenglao junpenglao merged commit 4ea8dde into pymc-devs:main Sep 15, 2022
@markusschmaus
Copy link
Contributor Author

  • For ASVGD forward the key word arguments start and random_seed to the constructor of the default approximation FullRank instead of sending them to super().__init__ which can't process them

For the record, this is what caused the test to fail since it expected super().__init__ to raise a TypeError when it receives a start parameter.

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.

2 participants