test: add unit tests for RNN and MultimodalRNN models#936
Open
haoyu-haoyu wants to merge 1 commit intosunlabuiuc:masterfrom
Open
test: add unit tests for RNN and MultimodalRNN models#936haoyu-haoyu wants to merge 1 commit intosunlabuiuc:masterfrom
haoyu-haoyu wants to merge 1 commit intosunlabuiuc:masterfrom
Conversation
Add test_rnn.py with 12 test cases covering: TestRNN (8 tests): - Model initialization with correct attributes - Forward pass output structure and shapes - Backward pass gradient propagation - Embedding extraction via embed=True - Custom hyperparameters (embedding_dim, hidden_dim) - LSTM cell type variant - Vanilla RNN cell type variant - Bidirectional RNN variant TestMultimodalRNN (4 tests): - Initialization with correct sequential/non-sequential classification - Forward pass with mixed modalities (sequence + multi_hot + tensor) - Backward pass gradient propagation - Embedding extraction with correct mixed-modality dimensions Follows the established test pattern from test_mlp.py and test_tcn.py using create_sample_dataset with synthetic data. Ref sunlabuiuc#425
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.
Summary
Add
tests/core/test_rnn.pywith 12 test cases covering theRNNandMultimodalRNNmodels, which previously had no unit tests.TestRNN (8 tests)
test_model_initializationtest_model_forwardtest_model_backwardtest_model_with_embeddingembed=Truereturns patient embeddings of expected dimensiontest_custom_hyperparameterstest_rnn_type_lstmtest_rnn_type_vanillatest_bidirectionalTestMultimodalRNN (4 tests)
test_model_initializationtest_model_forwardtest_model_backwardtest_model_with_embeddingPattern
Follows the established test pattern from
test_mlp.pyandtest_tcn.py:create_sample_dataset()Ref #425