Open
Conversation
Implements Oh & Bui (2025) "Multi-View Contrastive Learning for Robust Domain Adaptation in Medical Time Series Analysis" (CHIL 2025). - pyhealth/models/multiview_contrastive.py: model with three-view encoding (temporal, derivative, frequency), three encoder backbones (Transformer/1D-CNN/GRU), and three fusion strategies (hierarchical attention, concat, mean) - tests/core/test_multiview_contrastive.py: synthetic-data unit tests covering init, forward, gradients, and view computation - examples/sleepEEG_epilepsy_multiview_contrastive.py: ablation over encoder backbones, view subsets, and fusion strategies - docs/api/models/pyhealth.models.MultiViewContrastive.rst and index update
- Switch TEMPERATURE from 0.5 to paper's 0.07 for sharper contrastive signal in NT-Xent - Unify evaluation forward path with fine-tune path via model(**batch), removing the hand-rolled view/fusion reconstruction that drifted from the trained forward and caused class-collapsed predictions - Refresh ablation_results.json with the corrected run
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.
Pull Request: MultiViewContrastive Model
Contributor: Juhwan Song (juhwans3@illinois.edu)
Type of contribution: Model
Original paper: Oh & Bui (2025), "Multi-View Contrastive Learning for Robust Domain Adaptation in Medical Time Series Analysis", CHIL 2025 Best Paper
High-level description
This PR adds the MultiViewContrastive model to PyHealth, implementing the multi-view contrastive learning framework from Oh & Bui (2025). The model constructs three views of a raw time-series signal (temporal, derivative, frequency), encodes each with an independent backbone, fuses them via hierarchical attention, and classifies the fused representation.
This fills a gap in PyHealth's model collection: while ContraWR and SparcNet exist for biosignal classification, neither supports cross-domain transfer learning on medical time series.
Key features:
encode_views()) for domain adaptationFile guide
pyhealth/models/multiview_contrastive.pypyhealth/models/__init__.pytests/core/test_multiview_contrastive.pyexamples/sleepEEG_epilepsy_multiview_contrastive.pydocs/api/models/pyhealth.models.MultiViewContrastive.rstdocs/api/models.rstTesting
All tests use small synthetic tensors (4 samples, 1 channel, 178 timesteps) and complete in milliseconds. Coverage includes:
encode_views()helperAblation study
The example script runs two ablation studies on SleepEEG→Epilepsy: