Enhance DeepHealth model to incorporate CHECKUP state tokens in next-step training and evaluation, update dataset cache versioning, and improve handling of observed event histories.

This commit is contained in:
2026-06-15 14:10:09 +08:00
parent 593ecd2e71
commit c3e49db859
8 changed files with 111 additions and 86 deletions

View File

@@ -192,10 +192,7 @@ def build_model_from_dataset(args: argparse.Namespace, cfg: Dict[str, Any], data
def load_model_state(model: torch.nn.Module, state_dict: Dict[str, Any]) -> None:
missing, unexpected = model.load_state_dict(state_dict, strict=False)
if missing or unexpected:
print(
f"[WARN] load_state_dict strict=False: missing={missing[:10]}, unexpected={unexpected[:10]}")
model.load_state_dict(state_dict, strict=True)
def validate_dataset_metadata(dataset: HealthDataset, cfg: Dict[str, Any]) -> None:
@@ -1495,8 +1492,8 @@ def main() -> None:
load_model_state(model, state_dict)
except RuntimeError as exc:
raise RuntimeError(
"Checkpoint vocabulary shape is incompatible with the no-event dataset/model setup. "
"Please ensure this run was trained with the current no-event vocabulary and matching labels file."
"Checkpoint vocabulary shape is incompatible with the dataset/model setup. "
"Please ensure this run was trained with the same special-token vocabulary and labels file."
) from exc
if model.token_embedding.num_embeddings != dataset.vocab_size or model.risk_head.out_features != dataset.vocab_size: