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

Remove logsoftmax #513

Merged
merged 19 commits into from
Sep 10, 2023
Merged

Conversation

Sara04
Copy link
Contributor

@Sara04 Sara04 commented Sep 7, 2023

Addressing the issue #511 by setting up the flag add_logsoftmax with a warning that the LogSoftmax as a final layer will be removed in the future. Proposed by @PierreGtch . Cf #457

sliwy
sliwy previously requested changes Sep 7, 2023
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.

Thx @Sara04 Great job! I like the idea of convention of having out_fun and the approach of LogSoftmax/Identity. Some details I want to discuss:

  1. I have doubts whether property called add_log_softmax is not misleading, suggesting that there is an action of adding log_softmax being performed. I have commented with some propositions (@bruAristimunha, @PierreGtch please tell what you think as well).
  2. If I understand well this PR we need to add add_log_softmax param in all the models as a parameter and then use it in the super.__init__(). In most of the models it is always set to True in super.__init__(), I left comments for some of the cases here.

Edit: I didn't notice that it is a draft, so maybe reviewed too early 😂

braindecode/models/base.py Outdated Show resolved Hide resolved
braindecode/models/base.py Show resolved Hide resolved
braindecode/models/base.py Show resolved Hide resolved
braindecode/models/eegconformer.py Show resolved Hide resolved
braindecode/models/hybrid.py Outdated Show resolved Hide resolved
braindecode/models/hybrid.py Show resolved Hide resolved
braindecode/models/tcn.py Show resolved Hide resolved
braindecode/models/tcn.py Show resolved Hide resolved
braindecode/models/usleep.py Show resolved Hide resolved
braindecode/models/deep4.py Outdated Show resolved Hide resolved
@Sara04
Copy link
Contributor Author

Sara04 commented Sep 8, 2023

Thank you very much for your comments, @sliwy ! 😄
I will reply to them one by one.

@PierreGtch
Copy link
Collaborator

PierreGtch commented Sep 8, 2023

Hi @sliwy, thanks for your review! We discuss your comments with Sara and I will answer them individually

@sliwy
Copy link
Collaborator

sliwy commented Sep 8, 2023

@Sara04 @PierreGtch based on this #513 (comment) I think that I may not understand well what the flow of logsoftmax is going to look like. For now, all models (or almost all) are created with softmax in the end. In the new flow if a user wants to have classification model would need to add softmax on their own?

@codecov
Copy link

codecov bot commented Sep 8, 2023

Codecov Report

Merging #513 (9f24993) into master (6f213a8) will decrease coverage by 0.05%.
The diff coverage is 90.90%.

❗ Current head 9f24993 differs from pull request most recent head be3455f. Consider uploading reports for the commit be3455f to get more accurate results

@@            Coverage Diff             @@
##           master     #513      +/-   ##
==========================================
- Coverage   84.37%   84.32%   -0.05%     
==========================================
  Files          63       63              
  Lines        4545     4569      +24     
==========================================
+ Hits         3835     3853      +18     
- Misses        710      716       +6     

@PierreGtch
Copy link
Collaborator

@Sara04 @PierreGtch based on this #513 (comment) I think that I may not understand well what the flow of logsoftmax is going to look like. For now, all models (or almost all) are created with softmax in the end. In the new flow if a user wants to have classification model would need to add softmax on their own?

Yes exactly, the user will have to add the softmax himself as this is standard practice. But in practice, you will not need to because if you use the nn.CrossEntropyLoss, it’s already integrated in the loss.

@sliwy
Copy link
Collaborator

sliwy commented Sep 8, 2023

ok, cool, sounds awesome!

@bruAristimunha bruAristimunha marked this pull request as ready for review September 9, 2023 17:41
@bruAristimunha bruAristimunha linked an issue Sep 9, 2023 that may be closed by this pull request
@bruAristimunha
Copy link
Collaborator

Can we merge this @Sara04, @PierreGtch and @sliwy? Looks okay for me.

Copy link
Collaborator

@PierreGtch PierreGtch left a comment

Choose a reason for hiding this comment

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

Just two small changes in case the add_log_softmax was already there before and defaulted to false: we should keep the same default.

Otherwise all good to merge! Thanks a lot @Sara04 for all this work!!!

braindecode/models/base.py Outdated Show resolved Hide resolved
braindecode/models/usleep.py Outdated Show resolved Hide resolved
braindecode/models/tcn.py Outdated Show resolved Hide resolved
bruAristimunha and others added 3 commits September 10, 2023 13:42
Co-authored-by: PierreGtch <25532709+PierreGtch@users.noreply.github.com>
Co-authored-by: PierreGtch <25532709+PierreGtch@users.noreply.github.com>
@bruAristimunha bruAristimunha enabled auto-merge (squash) September 10, 2023 11:55
@bruAristimunha bruAristimunha dismissed stale reviews from PierreGtch and sliwy September 10, 2023 11:56

changes were made

@bruAristimunha bruAristimunha merged commit 1391e7e into braindecode:master Sep 10, 2023
14 checks passed
@bruAristimunha
Copy link
Collaborator

Thank you @Sara04, @PierreGtch, @sliwy!

dcwil pushed a commit to dcwil/braindecode that referenced this pull request Sep 11, 2023
* Setting up logsoft max as an optional output function with a warning that it will be remove in the future

* Fix warning

* Remove add_log_softmax from mother class init and put it in model's init; fix hybrid and tidnet

* Move deprecation check before mother class init

* Remove deprecated argument from usleep

* Remove unused arguments, remove unnecessary part from docstring, update examples

* Removing conversion of classifier to regressor in examples

* Removing comment

* Flake8

* Update braindecode/models/usleep.py

Co-authored-by: PierreGtch <25532709+PierreGtch@users.noreply.github.com>

* Update braindecode/models/tcn.py

Co-authored-by: PierreGtch <25532709+PierreGtch@users.noreply.github.com>

* Fixing the warning

---------

Co-authored-by: PierreGtch <25532709+PierreGtch@users.noreply.github.com>
Co-authored-by: bruAristimunha <a.bruno@aluno.ufabc.edu.br>
@Sara04
Copy link
Contributor Author

Sara04 commented Sep 11, 2023

Thanks @PierreGtch , @sliwy , @bruAristimunha !

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.

Inherit from EEGModuleMixin
4 participants