Skip to content

Commit 46c97c8

Browse files
committed
add division lines for print outs
1 parent dbd1c61 commit 46c97c8

6 files changed

Lines changed: 36 additions & 12 deletions

File tree

src/_training/train.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ train_model(model, opt, train_dl, val_dl, ydim; compiled_loss=my_compiled_loss)
105105
"""
106106
function train_model(model, opt_state, train_dl, val_dl, output_dim;
107107
max_epochs=50, patience=10, min_delta=1e-4, print_every=100,
108-
test_set=false, compute_loss=nothing, compiled_loss=masked_mse)
108+
test_set=false, compute_loss=nothing, compiled_loss=masked_mse,
109+
show_header=true)
109110

110111
# Build compute_loss from compiled_loss if not provided directly
111112
if isnothing(compute_loss) && !isnothing(compiled_loss)
@@ -127,10 +128,12 @@ function train_model(model, opt_state, train_dl, val_dl, output_dim;
127128
val_losses = DEFAULT_FLOAT_TYPE[]
128129
val_r2_scores = DEFAULT_FLOAT_TYPE[]
129130

130-
vprintln(VERBOSITY_NORMAL, "Starting training for up to $max_epochs epochs...")
131-
vprintln(VERBOSITY_NORMAL, "Early stopping: patience=$patience, min_delta=$min_delta")
132-
vprintln(VERBOSITY_NORMAL, "Batch size: $(train_dl.batchsize), Total batches per epoch: $(length(train_dl))")
133-
vprintln(VERBOSITY_NORMAL, "-" ^ 50)
131+
if show_header
132+
vprintln(VERBOSITY_NORMAL, "Starting training for up to $max_epochs epochs...")
133+
vprintln(VERBOSITY_NORMAL, "Early stopping: patience=$patience, min_delta=$min_delta")
134+
vprintln(VERBOSITY_NORMAL, "Batch size: $(train_dl.batchsize), Total batches per epoch: $(length(train_dl))")
135+
vprintln(VERBOSITY_NORMAL, "-" ^ 50)
136+
end
134137

135138
for epoch in 1:max_epochs
136139
# Train one epoch

src/final_and_code/_helpers.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ end
4141

4242
"""Train final model and load best weights. Returns: (trained_model, stats)"""
4343
function _train_final_model!(setup, dl_train, dl_test; max_epochs=50, patience=10, print_every=100)
44-
vprintln(VERBOSITY_NORMAL, "🎯 Training final model (train+val combined)...")
44+
print_phase_banner(VERBOSITY_QUIET, "🎯 FINAL MODEL TRAINING (train+val combined)")
4545
best_state, stats = train_model(setup.model, setup.opt_state, dl_train, dl_test, setup.Ydim;
4646
max_epochs, patience, print_every, test_set=true, compiled_loss=setup.compiled_loss)
4747

src/final_and_code/train_code_processor.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ function train_code_processor(model, dataloader, proc_wrap;
3333
processor, opt_state = _init_processor(proc_wrap, model.hp, use_hard_mask, seed)
3434

3535
# Print header
36-
vprintln(VERBOSITY_NORMAL, "=" ^ 60)
37-
vprintln(VERBOSITY_NORMAL, "🔧 Training code processor (arch: $(proc_wrap.arch_type), use_hard_mask: $use_hard_mask)")
36+
print_phase_banner(VERBOSITY_QUIET, "🔧 CODE PROCESSOR TRAINING")
37+
vprintln(VERBOSITY_NORMAL, "Arch: $(proc_wrap.arch_type), use_hard_mask: $use_hard_mask")
3838
vprintln(VERBOSITY_NORMAL, "Seed: $seed, Epochs: $max_epochs")
39-
vprintln(VERBOSITY_NORMAL, "=" ^ 60)
4039

4140
# Training loop
4241
step = Ref(0)
@@ -50,10 +49,10 @@ function train_code_processor(model, dataloader, proc_wrap;
5049
end
5150

5251
# Print summary
53-
vprintln(VERBOSITY_QUIET, "=" ^ 60)
52+
vprintln(VERBOSITY_QUIET, "-" ^ 60)
5453
vprintln(VERBOSITY_QUIET, "Code processor training complete!")
5554
vprintln(VERBOSITY_QUIET, "Final loss: $(round(loss_history[end], digits=6))")
56-
vprintln(VERBOSITY_QUIET, "=" ^ 60)
55+
vprintln(VERBOSITY_QUIET, "-" ^ 60)
5756

5857
return processor, loss_history
5958
end

src/tune/_helpers.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ function _run_trial(trial, raw_data, create_model, randomize_batchsize,
4545
rng=MersenneTwister(rand(Random.GLOBAL_RNG, 1:typemax(Int))))
4646

4747
model_state, stats = train_model(setup.model, setup.opt_state, dl_train, dl_val, setup.Ydim;
48-
max_epochs, patience, print_every, compiled_loss=setup.compiled_loss)
48+
max_epochs, patience, print_every, compiled_loss=setup.compiled_loss,
49+
show_header=false)
4950

5051
r2, loss = stats[:best_r2], stats[:best_val_loss]
5152
num_params = sum(length, Flux.trainables(setup.model))

src/tune/tuning.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ function tune_hyperparameters(raw_data, create_model::Function;
1515
print_every=100, save_folder=nothing, use_cuda=true,
1616
loss_spec=(loss=Flux.mse, agg=StatsBase.mean), model_kwargs...)
1717

18+
print_phase_banner(VERBOSITY_QUIET, "🔍 HYPERPARAMETER TUNING — $n_trials trials")
19+
1820
results = DataFrame(seed=Int[], best_r2=DEFAULT_FLOAT_TYPE[], val_loss=DEFAULT_FLOAT_TYPE[], num_params=Int[])
1921
best_r2, best_model, best_seed, best_batch = -Inf, nothing, nothing, nothing
2022
save_file = isnothing(save_folder) ? nothing : _setup_save_file(save_folder)

src/verbosity.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,22 @@ function vprint(level::Integer, args...)
7979
_should_log(level) && print(args...)
8080
nothing
8181
end
82+
83+
"""
84+
print_phase_banner(level, title; width=60)
85+
86+
Print a centered, full-width banner bounded by long-dash rules announcing a
87+
high-level phase (e.g. tuning, final training, code-processor training).
88+
Gated by `level` exactly like [`vprintln`](@ref); defaults to a banner width
89+
of `width` characters and is preceded by a blank line so it stands out.
90+
"""
91+
function print_phase_banner(level::Integer, title::AbstractString; width::Integer=60)
92+
_should_log(level) || return nothing
93+
rule = "-" ^ width
94+
pad = max(0, (width - length(title)) ÷ 2)
95+
println()
96+
println(rule)
97+
println(" " ^ pad, title)
98+
println(rule)
99+
nothing
100+
end

0 commit comments

Comments
 (0)