-
Notifications
You must be signed in to change notification settings - Fork 2
/
car_15000.sh
95 lines (78 loc) · 5.63 KB
/
car_15000.sh
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
#!/bin/sh
#SBATCH --output=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_%j.out
pwd
hostname
date
CURRENT=$(date +"%Y-%m-%d_%T")
echo $CURRENT
slurm_output_bb = Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_bb_$CURRENT.out
slurm_output_train = Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_t_train_$CURRENT.out
slurm_output_test= Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_t_test_$CURRENT.out
slurm_output1=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_iter_1_$CURRENT.out
slurm_output2=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_iter_2_$CURRENT.out
slurm_output3=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_iter_3_$CURRENT.out
slurm_output_residual=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_iter_3_residual_$CURRENT.out
slurm_output_total=Path/Stanford_CXR/moie/cardiomegaly/performance/cardiomegaly_15000_performance_$CURRENT.out
echo "Stanford_CXR"
source Path/anaconda3/etc/profile.d/conda.sh
# conda activate python_3_7
conda activate python_3_7_rtx_6000
# Train BB of Stanford CXR
python ../../../codebase/train_BB_stanford_cxr.py --arch='densenet121' --selected-obs="cardiomegaly" --epochs 5 --labels "0 (No cardiomegaly)" "1 (cardiomegaly)" --domain_transfer "y" --tot_samples 15000 --checkpoint-mimic-cxr "mimic_checkpoint" > $slurm_output_bb
# Train SSL
python ../../../codebase/train_t_ssl_main.py \
--target_dataset "stanford_cxr" \
--source_dataset "mimic_cxr" \
--disease "cardiomegaly" \
--source-checkpoint-bb_path "lr_0.01_epochs_60_loss_CE" \
--source-checkpoint-bb "g_best_model_epoch_4.pth.tar" \
--source-checkpoint-t-path "lr_0.01_epochs_60_loss_BCE_W_flattening_type_flatten_layer_features_denseblock4" \
--source-checkpoint-t "g_best_model_epoch_10.pth.tar" \
--tot_samples 15000 >$slurm_output_train
# Test SSL to get concepts
python ../../../codebase/test_t_ssl_main.py \
--target_dataset "stanford_cxr" \
--source_dataset "mimic_cxr" \
--disease "cardiomegaly" \
--source-checkpoint-bb_path "lr_0.01_epochs_60_loss_CE" \
--source-checkpoint-bb "g_best_model_epoch_4.pth.tar" \
--source-checkpoint-t-path "lr_0.01_epochs_60_loss_BCE_W_flattening_type_flatten_layer_features_denseblock4" \
--source-checkpoint-t "g_best_model_epoch_10.pth.tar" \
--tot_samples 15000 >$slurm_output_test
# Transfer MOIE-CXR from MIMIC-CXR to Stanford CXR
# if `--initialize_w_mimic` == "y", we finetune both the selectors (pi) and the experts (g).
# if `--initialize_w_mimic` == "n", we finetune only the selectors (pi), not the experts (g).
python ../../../codebase/train_explainer_cxr_domain_transfer.py \
--target_dataset "stanford_cxr" \
--disease "cardiomegaly" \
--tot_samples 15000 \
--batch-size 64 \
--iter 1 --cov 0.4 --initialize_w_mimic "y" --epochs 5 > $slurm_output1
python ../../../codebase/train_explainer_cxr_domain_transfer.py \
--target_dataset "stanford_cxr" \
--disease "cardiomegaly" \
--tot_samples 15000 \
--batch-size 64 \
--iter 2 --prev_covs 0.4 --cov 0.3 --initialize_w_mimic "y" --epochs 5 \
--prev_chk_pt_explainer_folder "{soft_hard_filter}_concepts/seed_{seed}/cardiomegaly/densenet121_1028_lr_0.01_SGD_temperature-lens_7.6_cov_0.25_alpha_0.5_selection-threshold_0.5_lm_1024.0_lambda-lens_0.0001_alpha-KD_0.99_temperature-KD_20.0_hidden-layers_2020_input-size-pi_2048_layer_layer4_sample_15000" \
--checkpoint-model "best_model.pth.tar" > $slurm_output2
python ../../../codebase/train_explainer_cxr_domain_transfer.py \
--target_dataset "stanford_cxr" \
--disease "cardiomegaly" \
--tot_samples 15000 \
--batch-size 64 \
--iter 3 --prev_covs 0.4 0.3 --cov 0.3 --initialize_w_mimic "y" --epochs 5 \
--prev_chk_pt_explainer_folder "{soft_hard_filter}_concepts/seed_{seed}/cardiomegaly/densenet121_1028_lr_0.01_SGD_temperature-lens_7.6_cov_0.25_alpha_0.5_selection-threshold_0.5_lm_1024.0_lambda-lens_0.0001_alpha-KD_0.99_temperature-KD_20.0_hidden-layers_2020_input-size-pi_2048_layer_layer4_sample_15000" "{soft_hard_filter}_concepts/seed_{seed}/cardiomegaly/densenet121_1028_lr_0.01_SGD_temperature-lens_7.6_cov_0.25_alpha_0.5_selection-threshold_0.5_lm_1024.0_lambda-lens_0.0001_alpha-KD_0.99_temperature-KD_20.0_hidden-layers_2020_input-size-pi_2048_layer_layer4_sample_15000" \
--checkpoint-model "best_model.pth.tar" "best_model.pth.tar" > $slurm_output3
python ../../../codebase/train_explainer_cxr_domain_transfer.py \
--target_dataset "stanford_cxr" \
--expert-to-train "residual" \
--disease "cardiomegaly" \
--source-checkpoint-bb_path "lr_0.01_epochs_60_loss_CE" \
--source-checkpoint-bb "g_best_model_epoch_4.pth.tar" \
--tot_samples 15000 \
--batch-size 4 \
--iter 3 --prev_covs 0.4 0.3 --cov 0.3 --initialize_w_mimic "y" --epochs 5 \
--prev_chk_pt_explainer_folder "{soft_hard_filter}_concepts/seed_{seed}/cardiomegaly/densenet121_1028_lr_0.01_SGD_temperature-lens_7.6_cov_0.25_alpha_0.5_selection-threshold_0.5_lm_1024.0_lambda-lens_0.0001_alpha-KD_0.99_temperature-KD_20.0_hidden-layers_2020_input-size-pi_2048_layer_layer4_sample_15000" "{soft_hard_filter}_concepts/seed_{seed}/cardiomegaly/densenet121_1028_lr_0.01_SGD_temperature-lens_7.6_cov_0.25_alpha_0.5_selection-threshold_0.5_lm_1024.0_lambda-lens_0.0001_alpha-KD_0.99_temperature-KD_20.0_hidden-layers_2020_input-size-pi_2048_layer_layer4_sample_15000" \
--checkpoint-model "best_model.pth.tar" "best_model.pth.tar" > $slurm_output_residual
python ../../../codebase/performance_calculation_cxr_domain_transfer_main.py --iterations 3 --disease "cardiomegaly" --model "MoIE" --tot_samples 15000 --cov 0.4 0.3 0.3 --initialize_w_mimic "y" > $slurm_output_total