Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DualTVDD.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stephan Hilb
DualTVDD.jl
Commits
d4014190
Commit
d4014190
authored
2 years ago
by
Stephan Hilb
Browse files
Options
Downloads
Patches
Plain Diff
save more experiment output data and slightly refactor
parent
1397cb7b
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
scripts/run.jl
+8
-8
8 additions, 8 deletions
scripts/run.jl
scripts/run_experiments.jl
+35
-19
35 additions, 19 deletions
scripts/run_experiments.jl
scripts/util.jl
+12
-24
12 additions, 24 deletions
scripts/util.jl
src/chambolle.jl
+1
-1
1 addition, 1 deletion
src/chambolle.jl
with
56 additions
and
52 deletions
scripts/run.jl
+
8
−
8
View file @
d4014190
...
@@ -4,16 +4,16 @@ const datapath = joinpath(@__DIR__, "..", "data")
...
@@ -4,16 +4,16 @@ const datapath = joinpath(@__DIR__, "..", "data")
ctx
=
Util
.
Context
(
datapath
)
ctx
=
Util
.
Context
(
datapath
)
#ctx(experiment_convergence_test, "convergence/test")
#ctx(experiment_convergence_test, "
fd/
convergence/test")
ctx
(
experiment_convergence_denoising
,
"convergence/denoising"
)
ctx
(
experiment_convergence_denoising
,
"
fd/
convergence/denoising"
)
ctx
(
experiment_convergence_inpainting
,
"convergence/inpainting"
)
ctx
(
experiment_convergence_inpainting
,
"
fd/
convergence/inpainting"
)
ctx
(
experiment_convergence_opticalflow
,
"convergence/opticalflow"
)
ctx
(
experiment_convergence_opticalflow
,
"
fd/
convergence/opticalflow"
)
ctx
(
experiment_surrogate_outerinner
,
"surrogate/outerinner"
)
ctx
(
experiment_surrogate_outerinner
,
"
fd/
surrogate/outerinner"
)
ctx
(
experiment_surrogate_outerinner_ref
,
"surrogate/outerinner_ref"
)
ctx
(
experiment_surrogate_outerinner_ref
,
"
fd/
surrogate/outerinner_ref"
)
ctx
(
experiment_global_basic
,
"global/basic"
)
ctx
(
experiment_global_basic
,
"
fd/
global/basic"
)
# note: run these with multiple worker processes
# note: run these with multiple worker processes
# don't forget `@everywhere Pkg.activate(".")`
# don't forget `@everywhere Pkg.activate(".")`
ctx
(
experiment_scaling_opticalflow
,
"scaling/opticalflow"
)
ctx
(
experiment_scaling_opticalflow
,
"
fd/
scaling/opticalflow"
)
This diff is collapsed.
Click to expand it.
scripts/run_experiments.jl
+
35
−
19
View file @
d4014190
...
@@ -170,7 +170,7 @@ end
...
@@ -170,7 +170,7 @@ end
function
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
function
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
algs
=
comparison_algs
(
prob
;
τ
,
M
,
overlap
,
ninner
)
algs
=
comparison_algs
(
prob
;
τ
,
M
,
overlap
,
ninner
)
df
,
states
=
run_algs
(
algs
;
maxiters
=
maxiters
÷
10
)
do
state
df
,
states
=
run_algs
(
algs
;
maxiters
)
do
state
return
(
return
(
energy
=
energy
(
fetch
(
state
),
prob
),
energy
=
energy
(
fetch
(
state
),
prob
),
residual
=
residual
(
fetch
(
state
),
prob
))
residual
=
residual
(
fetch
(
state
),
prob
))
...
@@ -178,7 +178,8 @@ function compare_algs(prob; τ, M, overlap, maxiters, ninner)
...
@@ -178,7 +178,8 @@ function compare_algs(prob; τ, M, overlap, maxiters, ninner)
#filter!(:k => k -> k < maxiters / 10, df)
#filter!(:k => k -> k < maxiters / 10, df)
energymin
=
calc_energymin
(
prob
,
algs
.
glob
;
maxiters
)
# subtract minimal energy for logarithmic plot
energymin
=
calc_energymin
(
prob
,
algs
.
glob
;
maxiters
=
maxiters
*
10
)
for
x
in
names
(
df
)
for
x
in
names
(
df
)
contains
(
x
,
r
"_energy
$
"
)
||
continue
contains
(
x
,
r
"_energy
$
"
)
||
continue
df
[
!
,
Symbol
(
x
)]
.-=
energymin
df
[
!
,
Symbol
(
x
)]
.-=
energymin
...
@@ -257,7 +258,8 @@ function experiment_convergence_test(ctx)
...
@@ -257,7 +258,8 @@ function experiment_convergence_test(ctx)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
maxiters
,
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
maxiters
,
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
end
end
...
@@ -316,7 +318,8 @@ function experiment_scaling_opticalflow(ctx)
...
@@ -316,7 +318,8 @@ function experiment_scaling_opticalflow(ctx)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"timings.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"timings.csv"
),
df
)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
Mdir
,
M
=
prod
(
M
),
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
Mdir
,
M
=
prod
(
M
),
ntimings
,
stopenergy
,
ninner
,
ntimings
,
stopenergy
,
ninner
,
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
end
end
...
@@ -373,7 +376,8 @@ function _experiment_surrogate_outerinner(ctx, ref)
...
@@ -373,7 +376,8 @@ function _experiment_surrogate_outerinner(ctx, ref)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
#saveimg(joinpath(ctx.outdir, "output_glob.png"), fetch_u(states.glob))
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
minenergy_maxiters
,
maxiters
,
ninner
,
M
,
overlap
,
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
minenergy_maxiters
,
maxiters
,
ninner
,
M
,
overlap
,
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
end
end
...
@@ -382,7 +386,7 @@ function experiment_convergence_denoising(ctx)
...
@@ -382,7 +386,7 @@ function experiment_convergence_denoising(ctx)
λ
=
0.1
λ
=
0.1
β
=
0.
β
=
0.
maxiters
=
10000
0
maxiters
=
10000
ninner
=
100
ninner
=
100
M
=
(
2
,
2
)
M
=
(
2
,
2
)
...
@@ -401,8 +405,11 @@ function experiment_convergence_denoising(ctx)
...
@@ -401,8 +405,11 @@ function experiment_convergence_denoising(ctx)
df
,
states
,
energymin
=
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
df
,
states
,
energymin
=
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
saveimg
(
joinpath
(
ctx
.
outdir
,
"output_glob.png"
),
fetch_u
(
states
.
glob
))
for
alg
in
keys
(
states
)
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
noise_sigma
=
noise_σ
,
energymin
,
saveimg
(
joinpath
(
ctx
.
outdir
,
"output_"
*
string
(
alg
)
*
".png"
),
fetch_u
(
states
[
alg
]))
end
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
ninner
,
noise_sigma
=
noise_σ
,
energymin
,
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
end
end
...
@@ -411,7 +418,7 @@ function experiment_convergence_inpainting(ctx)
...
@@ -411,7 +418,7 @@ function experiment_convergence_inpainting(ctx)
λ
=
0.05
λ
=
0.05
β
=
0.001
β
=
0.001
maxiters
=
10000
0
maxiters
=
10000
ninner
=
100
ninner
=
100
M
=
(
2
,
2
)
M
=
(
2
,
2
)
...
@@ -430,8 +437,11 @@ function experiment_convergence_inpainting(ctx)
...
@@ -430,8 +437,11 @@ function experiment_convergence_inpainting(ctx)
df
,
states
,
energymin
=
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
df
,
states
,
energymin
=
compare_algs
(
prob
;
τ
,
M
,
overlap
,
maxiters
,
ninner
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
saveimg
(
joinpath
(
ctx
.
outdir
,
"output_glob.png"
),
fetch_u
(
states
.
glob
))
for
alg
in
keys
(
states
)
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
energymin
,
saveimg
(
joinpath
(
ctx
.
outdir
,
"output_"
*
string
(
alg
)
*
".png"
),
fetch_u
(
states
[
alg
]))
end
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
ninner
,
energymin
,
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
width
=
size
(
fo
,
2
),
height
=
size
(
fo
,
1
))
end
end
...
@@ -442,7 +452,7 @@ function experiment_convergence_opticalflow(ctx)
...
@@ -442,7 +452,7 @@ function experiment_convergence_opticalflow(ctx)
λ
=
0.002
λ
=
0.002
β
=
0.001
β
=
0.001
maxiters
=
10000
0
maxiters
=
10000
ninner
=
100
ninner
=
100
M
=
(
2
,
2
)
M
=
(
2
,
2
)
...
@@ -455,11 +465,16 @@ function experiment_convergence_opticalflow(ctx)
...
@@ -455,11 +465,16 @@ function experiment_convergence_opticalflow(ctx)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
CSV
.
write
(
joinpath
(
ctx
.
outdir
,
"energies.csv"
),
df
)
cflow
=
colorflow
(
fetch_u
(
first
(
states
));
maxflow
=
4.5
/
(
584
/
48
))
for
alg
in
keys
(
states
)
#p = plot(cflow); display(p)
u_nested
=
fetch_u
(
states
[
alg
])
save
(
joinpath
(
ctx
.
outdir
,
"flow.png"
),
cflow
)
u
=
reinterpret
(
reshape
,
Float64
,
u_nested
)
cflow
=
colorflow
(
u
;
maxflow
=
4.5
/
(
584
/
48
))
#p = plot(cflow); display(p)
save
(
joinpath
(
ctx
.
outdir
,
"flow_"
*
string
(
alg
)
*
".png"
),
cflow
)
end
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
energymin
,
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
ninner
,
energymin
,
width
=
size
(
f0
,
2
),
height
=
size
(
f0
,
1
))
width
=
size
(
f0
,
2
),
height
=
size
(
f0
,
1
))
end
end
...
@@ -475,7 +490,7 @@ function experiment_global_basic(ctx)
...
@@ -475,7 +490,7 @@ function experiment_global_basic(ctx)
λ
=
0.02
λ
=
0.02
β
=
1e-3
β
=
1e-3
#maxiters = 10000
0
#maxiters = 10000
maxiters
=
100
maxiters
=
100
ninner
=
1000
ninner
=
1000
...
@@ -524,7 +539,7 @@ function experiment_global_basic(ctx)
...
@@ -524,7 +539,7 @@ function experiment_global_basic(ctx)
#display(fetch_u(st))
#display(fetch_u(st))
#return
#return
df
,
states
=
run_algs
([
alg
];
maxiters
=
maxiters
)
do
state
df
,
states
=
run_algs
([
alg
];
maxiters
)
do
state
return
(
return
(
energy
=
energy
(
fetch
(
state
),
prob
),
energy
=
energy
(
fetch
(
state
),
prob
),
residual
=
residual
(
fetch
(
state
),
prob
))
residual
=
residual
(
fetch
(
state
),
prob
))
...
@@ -550,7 +565,8 @@ function experiment_global_basic(ctx)
...
@@ -550,7 +565,8 @@ function experiment_global_basic(ctx)
display
(
p
)
display
(
p
)
savedata
(
ctx
,
"data.tex"
;
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
ninner
,
savedata
(
joinpath
(
ctx
.
outdir
,
"data.tex"
);
lambda
=
λ
,
beta
=
β
,
tau
=
τ
,
maxiters
,
ninner
,
width
=
size
(
f
,
2
),
height
=
size
(
f
,
1
))
width
=
size
(
f
,
2
),
height
=
size
(
f
,
1
))
return
prob
return
prob
end
end
This diff is collapsed.
Click to expand it.
scripts/util.jl
+
12
−
24
View file @
d4014190
...
@@ -24,6 +24,10 @@ Context(ctx::Context, path::String; params...) =
...
@@ -24,6 +24,10 @@ Context(ctx::Context, path::String; params...) =
Context
(
joinpath
(
ctx
.
indir
,
path
),
joinpath
(
ctx
.
outdir
,
path
),
Context
(
joinpath
(
ctx
.
indir
,
path
),
joinpath
(
ctx
.
outdir
,
path
),
merge
(
ctx
.
params
,
NamedTuple
(
params
)),
merge
(
ctx
.
params
,
NamedTuple
(
params
)),
joinpath
(
ctx
.
path
,
path
))
joinpath
(
ctx
.
path
,
path
))
Context
(
ctx
::
Context
;
params
...
)
=
Context
(
ctx
.
indir
,
ctx
.
outdir
,
merge
(
ctx
.
params
,
NamedTuple
(
params
)),
ctx
.
path
)
"""
"""
(ctx::Context)(f, subdir; params...)
(ctx::Context)(f, subdir; params...)
...
@@ -34,19 +38,19 @@ parameters `params`.
...
@@ -34,19 +38,19 @@ parameters `params`.
function
(
ctx
::
Context
)(
f
::
Function
,
subdir
::
String
;
params
...
)
function
(
ctx
::
Context
)(
f
::
Function
,
subdir
::
String
;
params
...
)
# maybe debug output with params?
# maybe debug output with params?
subctx
=
Context
(
ctx
,
subdir
;
params
...
)
subctx
=
Context
(
ctx
,
subdir
;
params
...
)
mkpath
(
subctx
.
outdir
)
println
(
"starting experiment `
$
(subctx.path)` ..."
)
println
(
"starting experiment `
$
(subctx.path)` ..."
)
f
(
subctx
)
f
(
subctx
)
end
end
# LaTeX Data Output
# LaTeX Data Output
# TODO: don't depend on ctx.path and use filename only
savedata
(
filename
;
data
...
)
=
savedata
(
ctx
::
Context
,
filename
;
data
...
)
=
open
(
filename
;
write
=
true
)
do
io
open
(
joinpath
(
ctx
.
outdir
,
filename
);
write
=
true
)
do
io
_savedata
(
io
;
data
...
)
_savedata
(
io
,
ctx
.
path
;
data
...
)
end
end
function
_savedata
(
io
,
path
;
data
...
)
function
_savedata
(
io
;
data
...
)
isvalidname
(
x
)
=
contains
(
string
(
x
),
r
"^[^/
\\
]+
$
"
)
isvalidname
(
x
)
=
contains
(
string
(
x
),
r
"^[^/
\\
]+
$
"
)
# define tex command to access data
# define tex command to access data
...
@@ -63,7 +67,7 @@ function _savedata(io, path; data...)
...
@@ -63,7 +67,7 @@ function _savedata(io, path; data...)
# actual data encoded as tex-commands
# actual data encoded as tex-commands
write
(
io
,
"
\\
expandafter
\\
def"
)
write
(
io
,
"
\\
expandafter
\\
def"
)
write
(
io
,
"
\\
csname
$(texcmd)
/
$(path)
/
$(key)
\\
endcsname{"
)
write
(
io
,
"
\\
csname
$(texcmd)
/
\\
DataPrefix
/
$(key)
\\
endcsname{"
)
show
(
io
,
MIME
(
"text/latex"
),
value
)
show
(
io
,
MIME
(
"text/latex"
),
value
)
write
(
io
,
"}
\n
"
)
write
(
io
,
"}
\n
"
)
end
end
...
@@ -73,24 +77,8 @@ end
...
@@ -73,24 +77,8 @@ end
Base
.
show
(
io
,
::
MIME
"text/latex"
,
x
)
=
print
(
io
,
x
)
Base
.
show
(
io
,
::
MIME
"text/latex"
,
x
)
=
print
(
io
,
x
)
function
Base.show
(
io
::
IO
,
::
MIME
"text/latex"
,
x
::
AbstractFloat
)
function
Base.show
(
io
::
IO
,
::
MIME
"text/latex"
,
x
::
Union
{
Integer
,
AbstractFloat
})
exponent
=
x
==
0.
?
0
:
floor
(
Int
,
log10
(
x
))
print
(
io
,
"
\\
pgfmathprintnumber{"
,
x
,
"}"
)
if
abs
(
exponent
)
<=
3
print
(
io
,
"
\\
ensuremath{"
,
x
,
"}"
)
else
base
=
x
/
10.
^
exponent
print
(
io
,
"
\\
ensuremath{"
,
base
,
"
\\
cdot 10^{"
,
exponent
,
"}}"
)
end
end
function
Base.show
(
io
::
IO
,
::
MIME
"text/latex"
,
x
::
Integer
)
p
=
log10
(
x
)
pr
=
round
(
Int
,
p
)
if
x
==
10
^
pr
print
(
io
,
"
\\
ensuremath{10^{"
,
pr
,
"}}"
)
else
print
(
io
,
"
\\
ensuremath{"
,
x
,
"}"
)
end
end
end
end
end
This diff is collapsed.
Click to expand it.
src/chambolle.jl
+
1
−
1
View file @
d4014190
...
@@ -114,7 +114,7 @@ function step!(ctx::ChambolleState)
...
@@ -114,7 +114,7 @@ function step!(ctx::ChambolleState)
# p = (p + τ*grad(s)) / (1 + τ/λ|grad(s)|)
# p = (p + τ*grad(s)) / (1 + τ/λ|grad(s)|)
sgrad
=
map
(
kgrad
,
ctx
.
s
)
sgrad
=
map
(
kgrad
,
ctx
.
s
)
f
(
p
,
sgrad
,
λ
)
=
iszero
(
λ
)
?
zero
(
p
)
:
@inline
f
(
p
,
sgrad
,
λ
)
=
iszero
(
λ
)
?
zero
(
p
)
:
(
p
+
alg
.
τ
*
sgrad
)
./
(
1.
.+
projnorm
(
alg
.
τ
*
sgrad
,
alg
.
anisotropic
)
./
λ
)
(
p
+
alg
.
τ
*
sgrad
)
./
(
1.
.+
projnorm
(
alg
.
τ
*
sgrad
,
alg
.
anisotropic
)
./
λ
)
ctx
.
p
.=
f
.
(
ctx
.
p
,
sgrad
,
λ
)
ctx
.
p
.=
f
.
(
ctx
.
p
,
sgrad
,
λ
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment