Repository navigation
Conversation
initialize_pooling_layers builds an LSTM for pooling_method="rnn" and a Conv1d for pooling_method="conv", but pool_sequence had no branch for either value and raised "Invalid pooling method" on the first forward pass of every pooling architecture. Use the LSTM output at the last step for "rnn" and the convolution followed by global max pooling for "conv", and list the supported values in the model config docstrings. Fixes #481
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #481
Problem
pooling_method="rnn"andpooling_method="conv"were accepted by every pooling architecture (FTTransformer, TabTransformer, SAINT, Mambular, MambAttention, TabulaRNN). Each one then crashed on its first forward pass withValueError: Invalid pooling method.Root cause
BaseModel.initialize_pooling_layersbuildspooling_rnn(annn.LSTM) andconv1d_pooling(annn.Conv1d) for these two methods.BaseModel.pool_sequencenever used them and fell through to itselse: raise ValueError(...).Fix
pool_sequencenow applies the layers that are already built:"rnn"returns the LSTM output at the last sequence step, i.e.(batch, seq, hidden)→(batch, hidden)."conv"applies the 1-D convolution over the sequence, then global max pooling. This matches the existing comment onconv1d_pooling.No other pooling method changes. Model construction and parameter counts stay the same, because the layers were already being created.
Tests
New
TestRecurrentAndConvolutionalPoolingintests/core/test_base_model.py:"rnn"returns the last LSTM step and"conv"returns the global max of the convolution.All 14 new cases fail on
mainand pass with this change.Docs
pool_sequencenow has a NumPy-style docstring that lists every supported method.pooling_methoddocstrings of the six affected model configs list the valid values instead of('cls', 'avg', etc.).Checks
just test: 3250 passed, 46 skipped, 28 xfailed; coverage 91.32%just docs: build succeeded (warnings treated as errors)just check: all hooks passed (ruff, prettier, pyright)