Skip to content

Commit c2862ea

Browse files
committed
apply best param on GradientMPIMode and improve epochs print
1 parent 9c52f18 commit c2862ea

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ApplicationDrivenLearning"
22
uuid = "0856f1c8-ef17-4e14-9230-2773e47a789e"
33
authors = ["Giovanni Amorim", "Joaquim Garcia"]
4-
version = "0.1.2"
4+
version = "0.1.3"
55

66
[deps]
77
BilevelJuMP = "485130c0-026e-11ea-0f1a-6992cd14145c"

src/optimizers/gradient.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ function train_with_gradient!(
7272
# store and print cost
7373
trace[epoch] = C
7474
if verbose
75-
println("Epoch $epoch | Cost = $(round(C, digits=2))")
75+
dtime = time() - start_time
76+
println("Epoch $epoch | Time = $(round(dtime, digits=1))s | Cost = $(round(C, digits=2))")
7677
end
7778

7879
# evaluate if best model

src/optimizers/gradient_mpi.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ function train_with_gradient_mpi!(
106106
# store and print cost
107107
trace[epoch] = curr_C
108108
if verbose
109-
println("Epoch $epoch | Cost = $(round(curr_C, digits=2))")
109+
dtime = time() - start_time
110+
println("Epoch $epoch | Time = $(round(dtime, digits=1))s | Cost = $(round(curr_C, digits=2))")
110111
end
111112

112113
# evaluate if best model
@@ -129,6 +130,9 @@ function train_with_gradient_mpi!(
129130
is_done = true
130131
MPI.bcast(is_done, MPI.COMM_WORLD)
131132

133+
# fix best model
134+
apply_params(model.forecast, best_θ)
135+
132136
elseif JQM.is_worker_process()
133137
# continuoslly call pmap until controller is done
134138
while true

0 commit comments

Comments
 (0)