TransUnet_Phase1_Optuned / build_final_params.py
Zednation's picture
Add files using upload-large-folder tool
0fad642 verified
Raw
History Blame Contribute Delete
1.46 kB
import sys, json
sys.path.insert(0, '/workspace')
import optuna
import foldsrunner_simplified_after_ablation as m
# ---- Strategy 2: tuned values from the completed study ----
s2_tuned = {
"head_lr": 0.0003920673972242139,
"encoder_lr": 0.0002157696745589684,
"weight_decay": 2.5081156860452307e-05,
"dropout_p": 0.15427033152408348,
}
t2 = optuna.trial.FixedTrial(s2_tuned)
params2 = m.suggest_hyperparameters(t2, 2)
print("=== STRATEGY 2 FINAL PARAMS ===")
print(json.dumps(params2, indent=2, default=str))
# ---- Strategy 3: tuned values from trial 14 (the best), tmax forced to 4 per user override ----
s3_tuned = {
"rl_lr": 0.00020486876181579884,
"strategy3_delta_max": 0.1659233369433877,
"biou_reward_weight": 1.148240758703169,
"strategy3_aux_ce_weight": 0.4534450202097867,
"tmax": 4, # OVERRIDE: optuna found 7, user wants tmax=4 regardless (time/perf tradeoff)
"threshold": 0.5296248979380782,
}
t3 = optuna.trial.FixedTrial(s3_tuned)
params3 = m.suggest_hyperparameters(t3, 3)
print("\n=== STRATEGY 3 FINAL PARAMS (tmax overridden to 4) ===")
print(json.dumps(params3, indent=2, default=str))
with open('/workspace/TransUNet_Setup/best_params_strat2.json', 'w') as f:
json.dump(params2, f, indent=2, default=str)
with open('/workspace/TransUNet_Setup/best_params_strat3.json', 'w') as f:
json.dump(params3, f, indent=2, default=str)
print("\nWROTE both files to /workspace/TransUNet_Setup/")