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

Removed unncessary sigma in function elbo of gplvm.py (and save N^2+1 operations) #1685

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

joacorapela
Copy link
Contributor

PR type: enhancement

Related issue(s)/PRs:

Summary

In function elbo of gplvm.py the calculation of sigma is unnecessary.
Proposed changes

  • In function elbo of gplvm.py sigma is only used to first divide A and then to divide c. As A is only used to calculate c, we can avoid dividing A by sigma by dividing c by sigma2. In this way we save N^2 divisions (assuming N is the dimension of A) and one square root operation.
  • Equations explaining this pull request appear here
  • I tested that the resulting elbo is equal with the current version of the code and with the modification proposed here.

What alternatives have you considered?

Minimal working example

# Put your example code in here

Release notes

Fully backwards compatible: yes

If not, why is it worth breaking backwards compatibility:

PR checklist

  • New features: code is well-documented
    • detailed docstrings (API documentation)
    • notebook examples (usage demonstration)
  • The bug case / new feature is covered by unit tests
  • Code has type annotations
  • Build checks
    • I ran the black+isort formatter (make format)
    • I locally tested that the tests pass (make check-all)
  • Release management
    • RELEASE.md updated with entry for this change
    • New contributors: I've added myself to CONTRIBUTORS.md

@johnamcleod
Copy link
Contributor

Hi @joacorapela, thanks for raising this PR. It looks like the unit test failure is nothing to do with your code. If you pull the in latest changes from develop all of the tests should pass.

@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #1685 (9f110b6) into develop (55690c7) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1685      +/-   ##
===========================================
- Coverage    97.30%   97.30%   -0.01%     
===========================================
  Files           90       90              
  Lines         4117     4116       -1     
===========================================
- Hits          4006     4005       -1     
  Misses         111      111              
Impacted Files Coverage Δ
gpflow/models/gplvm.py 99.21% <100.00%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55690c7...9f110b6. Read the comment docs.

@joacorapela
Copy link
Contributor Author

@johnamcleod my pull request has not been incorporated into the develop branch. Is there any problem or do I need to be more patient? Thanks.

@vdutor
Copy link
Contributor

vdutor commented Jun 1, 2021

LGTM, can we do the same simplification in the predict_f?

@st--
Copy link
Member

st-- commented Oct 26, 2021

@joacorapela if @vdutor is happy with it, we can merge it as is, but would be good to hear your thoughts on the same simplification for predict_f.: )

@joacorapela
Copy link
Contributor Author

@vdutor @st-- I was learning about predict_f and realised of, what I think is, an error in the prediction function. I open issue #1753 about this. I would appreciate your feedback on it. Thanks

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

4 participants