-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexperiment_no_time.sh
More file actions
executable file
·97 lines (80 loc) · 3.37 KB
/
experiment_no_time.sh
File metadata and controls
executable file
·97 lines (80 loc) · 3.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# === "No Time" Ablation Batch Launcher ===
# Runs all 4 tasks with no-time triplet variant × 10 seeds (0-9)
# Tests the impact of removing temporal information from triplet representations
# Simple logging with timing and system details
LOG_FILE="no_time_ablation_run_log.txt"
touch "$LOG_FILE"
TASKS=(
"mortality/in_hospital/first_24h"
"mortality/in_icu/first_24h"
"mortality/post_hospital_discharge/1y"
"readmission/30d"
)
VARIANT="no_time"
EPOCHS=10
SEEDS=(0 1 2 3 4 5 6 7 8 9) # 10 seeds as requested
# --- System Info ===
BATCH_START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
HOSTNAME=$(hostname)
PYTHON_VERSION=$(python --version 2>&1)
echo "=== Starting 'No Time' Ablation Experiments - $BATCH_START_TIME ===" | tee -a "$LOG_FILE"
echo "Host: $HOSTNAME | Python: $PYTHON_VERSION" | tee -a "$LOG_FILE"
echo "Total runs: $((${#TASKS[@]} * ${#SEEDS[@]}))" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
RUN_COUNT=0
TOTAL_RUNS=$((${#TASKS[@]} * ${#SEEDS[@]}))
for TASK in "${TASKS[@]}"; do
for SEED in "${SEEDS[@]}"; do
RUN_COUNT=$((RUN_COUNT + 1))
RUN_START_TIME=$(date '+%Y-%m-%d %H:%M:%S')
RUN_START_TIMESTAMP=$(date +%s)
echo "[$RUN_COUNT/$TOTAL_RUNS] Launching: Task='${TASK}' Variant='${VARIANT}' Seed=${SEED} - Started: $RUN_START_TIME"
# --- Activate environment ---
source .rqvenv/bin/activate
# --- Set config ---
EXPERIMENT_NAME="triplet_mtr" # This uses the no_time encoder via a branch
RUN_GROUP_NAME="no_time_ablation_multi"
SAFE_TASK_NAME="${TASK//\//_}"
ACCELERATOR="auto"
PRECISION="32"
STRATEGY="auto"
DEVICES=1
BATCH_SIZE=64
TOKEN_DIM=128
LOGGER="csv"
RUN_OUTPUT_DIR="results/${RUN_GROUP_NAME}/${EXPERIMENT_NAME}/${SAFE_TASK_NAME}/seed${SEED}_epochs${EPOCHS}"
mkdir -p "$RUN_OUTPUT_DIR"
# --- Run ---
meds-torch-train \
experiment=${EXPERIMENT_NAME} \
paths.data_dir=triplet_tensors \
paths.meds_cohort_dir=MEDS_cohort \
paths.output_dir=${RUN_OUTPUT_DIR} \
data.task_name=${TASK} \
data.task_root_dir=MEDS_cohort/tasks \
trainer.accelerator=${ACCELERATOR} \
trainer.devices=${DEVICES} \
trainer.precision=${PRECISION} \
trainer.strategy=${STRATEGY} \
logger=${LOGGER} \
seed=${SEED} \
++model.token_dim=${TOKEN_DIM} \
++data.dataloader.batch_size=${BATCH_SIZE} \
++trainer.max_epochs=${EPOCHS} \
++data.dataloader.num_workers=6 \
hydra.searchpath="[pkg://meds_torch.configs,meds-torch/MIMICIV_INDUCTIVE_EXPERIMENTS/configs/meds-torch-configs]"
EXIT_CODE=$?
RUN_END_TIME=$(date '+%Y-%m-%d %H:%M:%S')
RUN_DURATION=$(($(date +%s) - RUN_START_TIMESTAMP))
RUN_DURATION_FORMATTED=$(printf "%02d:%02d:%02d" $((RUN_DURATION/3600)) $((RUN_DURATION%3600/60)) $((RUN_DURATION%60)))
# Log the result
if [[ $EXIT_CODE -eq 0 ]]; then
echo "✅ SUCCESS: $TASK, $VARIANT, seed=$SEED | Duration: $RUN_DURATION_FORMATTED | Started: $RUN_START_TIME | Ended: $RUN_END_TIME | Python: $PYTHON_VERSION | Host: $HOSTNAME" | tee -a "$LOG_FILE"
else
echo "❌ FAILED: $TASK, $VARIANT, seed=$SEED | Duration: $RUN_DURATION_FORMATTED | Started: $RUN_START_TIME | Ended: $RUN_END_TIME | Python: $PYTHON_VERSION | Host: $HOSTNAME" | tee -a "$LOG_FILE"
fi
echo ""
done
done
echo "=== Completed all 'No Time' Ablation Experiments - $(date) ===" | tee -a "$LOG_FILE"