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 implementation of Functional Neural Process #187

Merged
merged 113 commits into from
Feb 5, 2021
Merged

Conversation

dereklhansen
Copy link
Contributor

This adds an implementation of the Functional Neural Process (FNP) to the repo.

In addition to the implementation of FNP, this PR currently adds two working examples of the FNP on synthetic data (located in 'case_studies/fnp':

  • A one-dimensional example which illustrates different variants of the FNP
  • An example on generated star-like objects which exhibit a counter-clockwise rotation

This commit moves a lot of the code that was in the
onedim.py file into the main fnp.py file. This lets us
write tests using the one dimensional FNP example

Squashed commit of the following:

commit 0db2d3e032d9e8fd4481a8311379234b57c6384f
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 16:06:36 2021 -0500

    Incorporated the one dimensional example as a unit test for FNP

commit cda0ce36ff39f49cc2c19ef27dba796ceaf47740
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 15:37:44 2021 -0500

    Got the RegressionFNP tested in one dimensional case

commit 754c9093abae98915db50da1e81bbd1e0a3d6450
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 14:17:46 2021 -0500

    Moved onedim training and visualize to fnp.py

commit 41aa5921416fcded2a55a97ef208dc0baf934fd1
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 14:11:03 2021 -0500

    Made od an argument rather than global

commit 5dd7c50be4479d8c8b5bbf569d747e36c21ed75b
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 14:06:23 2021 -0500

    Moved OneDimDataset into fnp.py

commit 263f8397be6ecba7faba758691ae501fa6b8161c
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 14:01:56 2021 -0500

    ensure that the indices match those from before

commit 2c22b0d438a6fb81a76ceb0eb988ff48f24d4917
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 13:51:59 2021 -0500

    Deleted old onedim dataset code

commit dc90af2fc86ab50e14d90a77e02f329456d3496e
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 13:18:31 2021 -0500

    Moved onedim dataset into a class
Squashed commit of the following:

commit d7695879fad3f469305df2bb0b3c09e49b33a425
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 18:38:32 2021 -0500

    Added test of star rotation

commit 5ef52ce57e9dcef42ef4421033a4c41a6d7b153e
Author: Derek Hansen <dereklh@umich.edu>
Date:   Fri Jan 22 17:26:01 2021 -0500

    Moved rotate_dgp.py code into fnp.py
@codecov
Copy link

codecov bot commented Jan 22, 2021

Codecov Report

Merging #187 (80dbbaf) into master (bd4ef0b) will increase coverage by 0.29%.
The diff coverage is 97.25%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #187      +/-   ##
==========================================
+ Coverage   96.29%   96.58%   +0.29%     
==========================================
  Files          13       15       +2     
  Lines        1672     1963     +291     
==========================================
+ Hits         1610     1896     +286     
- Misses         62       67       +5     
Flag Coverage Δ
unittests 96.58% <97.25%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
bliss/utils.py 96.77% <96.77%> (ø)
bliss/models/fnp.py 97.37% <97.37%> (ø)
bliss/sleep.py 96.28% <0.00%> (+1.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 bd4ef0b...02b8a23. Read the comment docs.

@dereklhansen
Copy link
Contributor Author

  • Remove the sklearn dependency since it's only used for the StandardScaler() in the test code

Copy link
Contributor

@jeff-regier jeff-regier left a comment

Choose a reason for hiding this comment

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

Nice. This is very readable code. Good to wait for reviews from @ismael-mendoza and @Runjing-Liu120 before merging since this is such a major PR (although much more manageable now that I see how it is organized)

@jeff-regier
Copy link
Contributor

Looks good to me. @ismael-mendoza @Runjing-Liu120 if you have feedback please try to weigh in sometime today

@Runjing-Liu120
Copy link
Contributor

Looks good to me, too. The hard part will be figuring out how to add this to our wake.py / decoder.py files -- we'll have to think carefully about that. But this is great so far!

@ismael-mendoza
Copy link
Collaborator

Hi @jeff-regier and @dereklhansen , I'll be done with my review shortly

@dereklhansen
Copy link
Contributor Author

dereklhansen commented Feb 5, 2021

There seems to be a problem with the CI environment that is causing the latest tests to fail. The latest commit I pushed shouldn't have caused this error.

I found a bug report on the poetry repo (issue 3650)

Copy link
Collaborator

@ismael-mendoza ismael-mendoza left a comment

Choose a reason for hiding this comment

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

Looks really good @dereklhansen, thanks for adding this code. I just had a couple of suggestions/questions.

bliss/models/fnp.py Outdated Show resolved Hide resolved
bliss/models/fnp.py Outdated Show resolved Hide resolved
bliss/models/fnp.py Outdated Show resolved Hide resolved
bliss/models/fnp.py Show resolved Hide resolved
bliss/models/fnp.py Outdated Show resolved Hide resolved
tests/test_fnp.py Outdated Show resolved Hide resolved
tests/test_fnp.py Outdated Show resolved Hide resolved
@dereklhansen
Copy link
Contributor Author

I added a fix for the poetry CI issues in #210

@dereklhansen dereklhansen merged commit b457e23 into master Feb 5, 2021
@dereklhansen dereklhansen deleted the derek/fnp branch February 5, 2021 20:16
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.

4 participants