Add training scripts for all-future and next-step supervision with DeepHealth

- Implement `train_all_future.py` for training with query-conditioned all-future supervision.
- Implement `train_next_step.py` for training with next-token/next-time-point supervision.
- Introduce `train_util.py` for shared utility functions including logging, dataset splitting, and model checkpointing.
- Enhance argument parsing for both training scripts to accommodate new parameters.
- Update loss functions and model configurations to support the new training paradigms.
This commit is contained in:
2026-06-13 11:42:04 +08:00
parent 034d8065a7
commit 46a3dfe628
12 changed files with 1927 additions and 1273 deletions

View File

@@ -223,7 +223,7 @@ all-future / query-conditioned 监督:
## 训练
当前 `train.py` 支持 next-token 和 all-future 两类训练入口:
当前 `train_next_step.py` / `train_all_future.py` 支持 next-token 和 all-future 两类训练入口:
- `--model_target_mode next_token`
- 使用 `NextStepHealthDataset`
@@ -235,7 +235,7 @@ all-future / query-conditioned 监督:
- 不使用 readout直接对 query hidden 计算风险
- `--dist_mode exponential/weibull/mixed` 分别搭配 `ExponentialLoss`、`WeibullLoss`、`MixedLoss`
当前 `train.py` 支持所有已有训练目标定义的组合:
当前 `train_next_step.py` / `train_all_future.py` 支持所有已有训练目标定义的组合:
| 训练模式 | 时间模式 | 分布/监督 | 默认 loss/readout |
| --- | --- | --- | --- |
@@ -248,7 +248,7 @@ all-future / query-conditioned 监督:
示例:
```bash
python train.py \
python train_next_step.py \
--data_prefix ukb \
--labels_file labels.csv \
--model_target_mode next_token \
@@ -262,7 +262,7 @@ python train.py \
all-future 示例:
```bash
python train.py \
python train_next_step.py \
--data_prefix ukb \
--labels_file labels.csv \
--model_target_mode all_future \
@@ -273,10 +273,10 @@ python train.py \
选择额外信息变量:
```bash
python train.py --extra_info_types_file extra_info_types_smoking_alcohol_bmi.txt
python train_next_step.py --extra_info_types_file extra_info_types_smoking_alcohol_bmi.txt
```
`train.py` 只接受 `--extra_info_types_file` 指定变量列表,不接受在 CLI 里直接输入 type id。文件可以每行一个 type id也可以带 `#` 注释;如果不传 `--extra_info_types_file`,默认使用全部 other-info type。
`train_next_step.py` / `train_all_future.py` 只接受 `--extra_info_types_file` 指定变量列表,不接受在 CLI 里直接输入 type id。文件可以每行一个 type id也可以带 `#` 注释;如果不传 `--extra_info_types_file`,默认使用全部 other-info type。
训练输出的 `train_config.json` 会记录: