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

Integrated GPFA #233

Merged
merged 38 commits into from
Jul 31, 2019
Merged

Integrated GPFA #233

merged 38 commits into from
Jul 31, 2019

Conversation

dizcza
Copy link
Member

@dizcza dizcza commented Jul 3, 2019

Only gpfa method is integrated here among all other choices in neural_trajectory.
We'll add new functionality once it's implemented by our researchers.

@coveralls
Copy link
Collaborator

coveralls commented Jul 3, 2019

Coverage Status

Coverage increased (+16.8%) to 87.727% when pulling 6101bbb on INM-6:feature/gpfa into d6822d6 on NeuralEnsemble:master.

@mdenker mdenker requested review from alperyeg and Junji110 July 3, 2019 13:12
@mdenker mdenker self-requested a review July 3, 2019 13:12
Copy link
Contributor

@alperyeg alperyeg left a comment

Choose a reason for hiding this comment

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

I made a minor review. Mostly concerning documentation. I hope to find some time to have a more detailed look.

elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa_src/gpfa_util.py Show resolved Hide resolved
elephant/utils.py Outdated Show resolved Hide resolved
@alperyeg alperyeg self-requested a review July 3, 2019 14:19
@dizcza
Copy link
Member Author

dizcza commented Jul 3, 2019

As a side note, gpfa can be implemented as a class. Doing so will reduce a large number of repeated arguments (like verbose, num-of-iters, etc.) that are passed all over the gpfa functionality. I guess, if we agree to this, it'll be a separate PR.

elephant/test/test_gpfa.py Outdated Show resolved Hide resolved
elephant/test/test_gpfa.py Outdated Show resolved Hide resolved
elephant/test/test_gpfa.py Outdated Show resolved Hide resolved
elephant/utils.py Outdated Show resolved Hide resolved
@Junji110
Copy link
Contributor

Junji110 commented Jul 3, 2019

I found there are number of cases where assert is used to check the type or shape of input variables, but I don't think this is a proper usage of assert; you should rather raise ValueError in such cases.
To my understanding, assert should be used to check the internal logic of the code, but not to check whether users use the code in a proper way.

elephant/gpfa.py Outdated Show resolved Hide resolved
@dizcza
Copy link
Member Author

dizcza commented Jul 3, 2019

I found there are number of cases where assert is used to check the type or shape of input variables, but I don't think this is a proper usage of assert; you should rather raise ValueError in such cases.
To my understanding, assert should be used to check the internal logic of the code, but not to check whether users use the code in a proper way.

Actually yes, ValueError better fits the philosophy of checking the function input, while asserts are used as "I swear this cannot happen". I'll go through input checking asserts and change them to ValueError.

@pep8speaks
Copy link

pep8speaks commented Jul 5, 2019

Hello @dizcza! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 116:52: E231 missing whitespace after ','

Comment last updated at 2019-07-31 13:28:51 UTC

@Junji110
Copy link
Contributor

Junji110 commented Jul 5, 2019

I've refactored unit tests and added a new test on dimensionality reduction performance of GPFA

Copy link
Member

@mdenker mdenker left a comment

Choose a reason for hiding this comment

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

Wow, huge amount of work getting this ported!
Minimal example works for me. I have started a first round of comments where I think a first major issue is to spend some more work on the function documentations, since they are still very difficult for users not familiar with the method. I'd be happy to assist with this as a novice user.

elephant/gpfa_src/README.md Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa_src/gpfa_util.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
elephant/gpfa.py Outdated Show resolved Hide resolved
R: ndarray of shape (#units, #latent_vars)
observation noise covariance

seqs_train: numpy.recarray
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure I understand the advantage of using recarray instead of a classic list of dict here? Would

seqs_train['y'][0] # recarrays, trial 0

be preferrable over

seqs_train[0]['y'] # list of dicts, trial 0

from a user perspective?

Copy link
Member Author

Choose a reason for hiding this comment

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

I fully agree not using np.recarray. The authors should provide a clear reason why they stick to np.recarray over python-friendly structures. Apart from confusing the users (and probably developers as well), it has several disadvantages during the test setup and future maintenance.

Copy link
Contributor

@Junji110 Junji110 Jul 11, 2019

Choose a reason for hiding this comment

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

I also thought to define seqs_train as a list of dicts rather than a recarray, but I found that there are many parts in the code where seqs_train['y'] is subjected to vector operation, which cannot be done quickly with dicts, so I gave up.
We could still define seqs_train as a dict of arrays (of the same length, i.e., # of trials) representing y, x, and so on, but it would require a total rewrite of the whole code.

By the way, for a recarray seqs_train, seqs_train['y'][0] is identical to seqs_train[0]['y'].

@dizcza
Copy link
Member Author

dizcza commented Jul 31, 2019

TODO list:

  1. Replace np.recarray -> dict: hide np.recarray from the user in GPFA internal private functional, but still operate with dicts as input and output type.
  2. Add an example where test data is used as not a part of the training data.
  3. Move functions to OOP.

@dizcza dizcza merged commit 36e6096 into NeuralEnsemble:master Jul 31, 2019
dizcza added a commit to INM-6/elephant that referenced this pull request Aug 1, 2019
commit 19d3c7b
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Thu Aug 1 15:09:34 2019 +0200

    fixed min requirements (NeuralEnsemble#235)

    * fixed min requirements

    * travis install libopenmpi-dev

    * added .coveragerc omit=elephant/test* rule not to count test files as source code

commit 36e6096
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Wed Jul 31 16:55:47 2019 +0200

    Integrated GPFA (NeuralEnsemble#233)

    * Rename neural_trajectory to gpfa and refactor the codes accordingly

    * Remove codes related to the (not fully implemented) cross-validation feature

    * added tqdm as an extra requirement

    * push coverage only for requirements-extras test

    * gpfa verbose flag; added licence in the docs

    * Fixed and extended documentation, removed misleading function outputs.

commit d6822d6
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Tue Jul 23 16:35:45 2019 +0300

    Acknowledgments (NeuralEnsemble#241)

    * acknowledgments

    * removed reference file AUTHORS.txt

    * recursive-exclude . *~

commit 6fd3a5b
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Mon Jul 22 23:14:36 2019 +0300

    Release v0.6.3 (NeuralEnsemble#240)

    * Release v0.6.3

    * Update doc/reference/waveform_features.rst

    Co-Authored-By: Michael Denker <m.denker@fz-juelich.de>

commit c013e39
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Sun Jul 21 09:18:03 2019 +0300

    elephant dir packages are back (NeuralEnsemble#239)

    * reverted removed imports of elephant's internal packages; download fim during the setup

    * download fim from tools/fim_manager.py

    * dummy tools/__init__.py to support py2

    * include requirements in MANIFEST back

    * fixed spade licence typo

    * included waveform_features module; removed tools; don't donwload fim at setup while macking a tarball with 'sdist' command

    travis not fixed downloading fim

    * skip time consuming test_spade_cpp if not HAVE_FIM

    * travis pip install generated tarball

    * recursive-include elephant *.py

commit 3c30574
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Wed Jul 10 18:21:37 2019 +0200

    Butterworth supports sosfiltfilt filter_function (NeuralEnsemble#234)

    * Butterworth supports sosfiltfilt filter_function

    * higher order filters comment
dizcza added a commit to INM-6/elephant that referenced this pull request Aug 13, 2019
commit caa2110
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Tue Aug 13 10:03:45 2019 +0300

    explain and ignore warnings during the tests (NeuralEnsemble#238)

    * explain and ignore warnings during the tests

    * scipy v0.18.0

    * fixed min-req tests: scipy v0.19.0

    * exclude min-requirements tests back

    * fixed division by zero

commit 19d3c7b
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Thu Aug 1 15:09:34 2019 +0200

    fixed min requirements (NeuralEnsemble#235)

    * fixed min requirements

    * travis install libopenmpi-dev

    * added .coveragerc omit=elephant/test* rule not to count test files as source code

commit 36e6096
Author: Danylo Ulianych <dizcza@gmail.com>
Date:   Wed Jul 31 16:55:47 2019 +0200

    Integrated GPFA (NeuralEnsemble#233)

    * Rename neural_trajectory to gpfa and refactor the codes accordingly

    * Remove codes related to the (not fully implemented) cross-validation feature

    * added tqdm as an extra requirement

    * push coverage only for requirements-extras test

    * gpfa verbose flag; added licence in the docs

    * Fixed and extended documentation, removed misleading function outputs.
@Moritz-Alexander-Kern Moritz-Alexander-Kern deleted the feature/gpfa branch September 6, 2022 07:54
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.

6 participants