CLAM Training and Evaluation
Use this sub-skill when a user needs to turn extracted CLAM feature bags into train/validation/test splits, train CLAM_SB, CLAM_MB, or MIL baselines, evaluate checkpoints, or debug task/model/data mismatches.
Route First
- For raw whole-slide segmentation, patch coordinates, presets, or stitched QC images, use
../wsi-preprocessing/SKILL.md. - For ResNet50, UNI, or CONCH feature extraction and
pt_files/creation, use../feature-extraction/SKILL.md. - For attention heatmaps and interpretation from trained checkpoints, use
../heatmap-visualization/SKILL.md. - Stay here for dataset CSV schemas, split generation,
main.pytraining,eval.pycheckpoint evaluation, model constructor choices, and metrics outputs.
Operating Checklist
- Confirm the dataset CSV has
case_id,slide_id, and the selected label column;slide_idmust match feature file basenames. - Confirm features are arranged as
DATA_ROOT_DIR/<dataset_feature_dir>/pt_files/<slide_id>.ptand that--embed_dimmatches the encoder used upstream. - Generate or select
splits_<fold>.csvfiles withtrain,val, andtestcolumns before training. - For custom tasks, update the CLAM task choices and dataset constructor branches consistently in split, training, and evaluation entrypoints.
- Train with
main.py, matching--task,--model_type,--subtyping, loss flags, fold range, and split directory. - Evaluate with
eval.py, matching the checkpoint directory, model flags, task branch, fold range, split files, and feature dimension.
Bundled References
- Read
references/data-formats.mdwhen preparing dataset CSVs, feature folder layouts, label dictionaries, or split files. - Read
references/training-reference.mdwhen assembling amain.pycommand or explaining training outputs. - Read
references/evaluation-reference.mdwhen evaluating checkpoints or independent cohorts witheval.py. - Read
references/model-api.mdwhen selectingCLAM_SB,CLAM_MB,MIL_fc,MIL_fc_mc, dataset classes, losses, orembed_dimvalues. - Read
references/troubleshooting.mdwhen diagnosing missing columns, label mismatches, split paths,--subtypingassertions, SVM loss imports, or checkpoint shape errors.
Bundled Scripts
- Run
scripts/clam_split_recipe.pyto validate a CLAM dataset CSV and render a safecreate_splits_seq.pycommand without creating split files by default. - Run
scripts/clam_train_eval_command_builder.pyto render safemain.pyoreval.pycommands, check task/model/embed-dimension consistency, and preview output paths without training or loading checkpoints.
Safety Notes
- CLAM training, evaluation, and feature loading can require GPU memory, large
.ptbags, valid checkpoints, and optional packages such assmooth-topk; bundled helpers only validate inputs and build commands. - The CLAM source entrypoints are task-branch based. For new tasks, future agents should edit their own working CLAM copy rather than relying on hard-coded dummy tasks.
