Skip to content

Towards Unified Sequence Representation IV: Add Unified_RNN for SequenceProcessorV2 fields - #1353

Draft
Logiquo wants to merge 1 commit into
feat/seq-v2-3from
feat/seq-v2-4
Draft

Logiquo wants to merge 1 commit into
feat/seq-v2-3from
feat/seq-v2-4

Conversation

@Logiquo

@Logiquo Logiquo commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fourth PR in the stack toward a unified sequence representation, on top of #1352. It adds Unified_RNN, the first model that consumes SequenceProcessorV2 fields and per-step labels.

Changes

  • Each sequence_v2 field is embedded by SequenceEmbeddingModel and encoded bottom-up, level by level. A set level mean-pools each group; a sequence or series level runs an RNN over each group and keeps the last output. A group without records is skipped and summarized as zeros.
  • Static tensor fields are used directly or through a projection. The field summaries and statics are concatenated, and a linear layer predicts the label. Other processors are rejected; sequences, sets and tokens are expressed with sequence_v2.
  • hidden_dim, rnn_type, num_layers, dropout, bidirectional and time_feature take one value, or a {field: value} dict. time_feature adds the time since the previous record of the group on timed levels.
  • Per-step labels: one prediction per label record, from each field's top-level state after its last record at or before the label's time. A prediction never sees later records. Fields need a series top level, and bidirectional RNNs are rejected.
  • RNN and MultimodalRNN now point to Unified_RNN for per-step labels.
  • The per-step tests from Towards Unified Sequence Representation II: Move YAIB tasks and per-step labels to SequenceProcessorV2 #1347 also run with Unified_RNN, and the YAIB tasks are tested end to end with it.

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 75.13% (21398 / 28483 lines)

Modified file Coverage Lines
pyhealth/benchmarks/__init__.py 100.00% 2 / 2
pyhealth/benchmarks/_serialization.py 95.95% 71 / 74
pyhealth/benchmarks/base.py 98.33% 59 / 60
pyhealth/models/__init__.py 100.00% 54 / 54
pyhealth/models/base_model.py 92.81% 129 / 139
pyhealth/models/rnn.py 93.77% 346 / 369
pyhealth/models/vae.py 96.77% 90 / 93
pyhealth/processors/timeseries_processor.py 88.35% 91 / 103
pyhealth/tasks/__init__.py 89.74% 35 / 39
pyhealth/tasks/covid19_cxr_generation.py 100.00% 9 / 9

Workflow run · 2e7d1fa

Unified_RNN embeds each sequence_v2 field with SequenceEmbeddingModel and
encodes it bottom-up, level by level: a set level mean-pools each group,
a sequence or series level runs an RNN over each group and keeps the last
output. A group without records is skipped and summarized as zeros.
Static tensor fields are used directly or through a projection; the
summaries and statics are concatenated and a linear layer predicts the
label.

- Per-field settings (hidden_dim, rnn_type, num_layers, dropout,
  bidirectional, time_feature) take one value or a {field: value} dict.
- time_feature adds the time since the previous record of the group on
  timed levels.
- Per-step labels: one prediction per label record, from each field's
  top-level state after its last record at or before the label's time,
  so a prediction never sees later records. Fields need a series top
  level and the RNNs must be causal.
- RNN and MultimodalRNN now point to Unified_RNN for per-step labels.

This branch has not been deployed

No deployments
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