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

Automatically populate the signal-related parameters #517

Merged
merged 31 commits into from Sep 12, 2023

Conversation

PierreGtch
Copy link
Collaborator

@PierreGtch PierreGtch commented Sep 8, 2023

cf #488, #457

@PierreGtch
Copy link
Collaborator Author

@sliwy I merged the test_eeg_classifier.py and test_eeg_regressor.py tests and updated them to use a “realistic" fake model with input-related parameters.

Could you help me update the test you had in them?

@sliwy
Copy link
Collaborator

sliwy commented Sep 8, 2023

@PierreGtch what do you need from me? some specific test you think about?

@PierreGtch
Copy link
Collaborator Author

@sliwy I broke the tests:

  • test_trialwise_predict_and_predict_proba
  • test_cropped_predict_and_predict_proba
  • test_cropped_predict_and_predict_proba_not_aggregate_predictions
  • and test_predict_trials
    but I’m not familiar with the cropped parameter and the CroppedLoss. So not sure how to update them. Did you write them?

@sliwy
Copy link
Collaborator

sliwy commented Sep 8, 2023

taking a look!

@sliwy
Copy link
Collaborator

sliwy commented Sep 8, 2023

@PierreGtch let's move back here:
test_eegneuralnet.py is fixed in the PR: PierreGtch#3

When it comes to test_scoring.py and test_post_epoch_train_scoring it fails because we do not provide y in this line:
clf.fit(train_set, y=None, epochs=4)
and we use torchDataset but not BaseConcatDataset and not WindowsDataset so signal_kwargs['n_outputs'] is not set anywhere. We would need another elif for just plain torchDataset in _set_signal_args? what do you think?

@bruAristimunha
Copy link
Collaborator

Hey @PierreGtch and @sliwy,

Please ping me if you need any help to solve the design conflict. To be honest, I looked the discussion at the PierreGtch#3, and I still don't get the big picture. I am available to chat or meet if necessary.

@PierreGtch
Copy link
Collaborator Author

As discussed in PierreGtch#3, we deprecate passing an initialized module to _EEGNeuralNet and skip setting signal-related arguments in this case.

@codecov
Copy link

codecov bot commented Sep 10, 2023

Codecov Report

Merging #517 (0396d03) into master (997fda4) will increase coverage by 0.12%.
The diff coverage is 87.17%.

@@            Coverage Diff             @@
##           master     #517      +/-   ##
==========================================
+ Coverage   84.35%   84.48%   +0.12%     
==========================================
  Files          63       63              
  Lines        4578     4653      +75     
==========================================
+ Hits         3862     3931      +69     
- Misses        716      722       +6     

@PierreGtch PierreGtch marked this pull request as ready for review September 10, 2023 14:35
@PierreGtch
Copy link
Collaborator Author

@sliwy are you ok to merge this version?

@PierreGtch
Copy link
Collaborator Author

Hey @PierreGtch and @sliwy,

Please ping me if you need any help to solve the design conflict. To be honest, I looked the discussion at the PierreGtch#3, and I still don't get the big picture. I am available to chat or meet if necessary.

Sorry @bruAristimunha, missed your comment. The goal is to automatically populate all the signal-related parameters when we can and not break things when not possible.

Copy link
Collaborator

@sliwy sliwy left a comment

Choose a reason for hiding this comment

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

I would restore a test with initialized nn.Module provided to the EEGClassifer - the one that was failing before (for example test_post_epoch_train_scoring).
Let's check that the warning is shown and that the model is not reinitialized with default params.

Apart from that and some details (flake8, docstring and test with only pass) everything looks good to me! :)

test/unit_tests/test_eegneuralnet.py Show resolved Hide resolved
@robintibor
Copy link
Contributor

Hey @PierreGtch and @sliwy,
Please ping me if you need any help to solve the design conflict. To be honest, I looked the discussion at the PierreGtch#3, and I still don't get the big picture. I am available to chat or meet if necessary.

Sorry @bruAristimunha, missed your comment. The goal is to automatically populate all the signal-related parameters when we can and not break things when not possible.

I missed this, but would prefer we don't do that (deprecating passing initialized module). I think there is a tradeoff between automating more stuff (like setting parameter according to dataset) and being simpler/more transparent. So in my view should be fine to also pass initialized module, and in that case as is now, do not set parameters according to dataset... no reason to break this workflow I think...

@PierreGtch
Copy link
Collaborator Author

@robintibor I can just turn the warning into an info and remove the deprecated part

@robintibor
Copy link
Contributor

sounds sensible

@PierreGtch
Copy link
Collaborator Author

Then I'm ready to merge

@bruAristimunha bruAristimunha enabled auto-merge (squash) September 12, 2023 14:24
@bruAristimunha
Copy link
Collaborator

bruAristimunha commented Sep 12, 2023

Hi @sliwy!

I enabled auto merge, if good for you, just approve and will be merged.

@robintibor
Copy link
Contributor

Would be good to have some docs example for usage I think? To see how it all works?

@PierreGtch
Copy link
Collaborator Author

Yes it's planned but I will wait for #529 and #528

@bruAristimunha
Copy link
Collaborator

What's new checker is working (I hope) @PierreGtch

@bruAristimunha bruAristimunha merged commit ae843fe into braindecode:master Sep 12, 2023
16 checks passed
tgnassou pushed a commit to tgnassou/braindecode that referenced this pull request Sep 18, 2023
* Set signal-related parameters in check_data

* Merge tests for EEGClassifier and EEGRegressor

* Fix coquille

* Update test to use module mixin

* Rename clf to eegneuralnet in test

* Add preds fixture

* Update eegneuralnet.py and subclasses

* Update test_eegneuralnet.py

* restored previous tests behavior where nn layer is ignored and always returns mocked values

* Update whats_new.rst

* Use two different mock modules for test

* Rename mock modules

* Use set_params instead of vars

* Deprecate passing an initialized module and skip setting signal args in that case

* Remove unnecessary f-strings

* Try fix python 3.8

* Fix case with non torch dataset

* Try fix python 3.8

* Add docstrings for fit and partial_fit (already including braindecode#529)

* Test initialized module

* Fix Flake8

* Add email

* Remove deprecation of initialized module

---------

Co-authored-by: Maciej Sliwowski <macieksliwowski@gmail.com>
Co-authored-by: Bru <a.bruno@aluno.ufabc.edu.br>
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