Skip to content

Fix/mlp embedding#544

Merged
jhnwu3 merged 2 commits intomasterfrom
fix/mlp_embedding
Sep 12, 2025
Merged

Fix/mlp embedding#544
jhnwu3 merged 2 commits intomasterfrom
fix/mlp_embedding

Conversation

@jhnwu3
Copy link
Collaborator

@jhnwu3 jhnwu3 commented Sep 12, 2025

This pull request refactors the MLP model in pyhealth/models/mlp.py to simplify and centralize the embedding logic by introducing the new EmbeddingModel class. The changes improve maintainability and make the handling of different input types more consistent and modular.

Model architecture refactoring

  • Replaced custom embedding and linear layer management in the MLP model with a dedicated EmbeddingModel class for handling all embedding logic, reducing code duplication and complexity. [1] [2]
  • Updated the forward method to preprocess inputs, track reshaping information, and delegate embedding operations to EmbeddingModel, followed by pooling and concatenation of patient embeddings. [1] [2] [3]

Test data update

  • Modified the test sample in tests/core/test_mlp.py to add an additional condition to the input data, ensuring coverage of the updated embedding handling.

@jhnwu3 jhnwu3 merged commit 5200ac4 into master Sep 12, 2025
1 check passed
@jhnwu3 jhnwu3 deleted the fix/mlp_embedding branch September 12, 2025 16:59
dalloliogm pushed a commit to dalloliogm/PyHealth that referenced this pull request Nov 26, 2025
* use new EmbeddingModel approach

* updated test case to reflect variability in data

---------

Co-authored-by: John Wu <johnwu3@sunlab-serv-03.cs.illinois.edu>
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.

1 participant