Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 1D-Total variation prox #128

Merged
merged 9 commits into from
Aug 6, 2021
Merged

Add 1D-Total variation prox #128

merged 9 commits into from
Aug 6, 2021

Conversation

fabian-sp
Copy link
Contributor

I created the main file. Can you help me with what else I need to add? Also I am not familiar to programming in Julia, so if there are any best practices I am violating, let me know.

Copy link
Member

@lostella lostella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for this addition! I left some comments inline.

I think two things are missing:

src/functions/normTV.jl Outdated Show resolved Hide resolved
src/functions/normTV.jl Outdated Show resolved Hide resolved
src/functions/normTV.jl Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 3, 2021

Codecov Report

Merging #128 (eb72536) into master (4ab5afa) will decrease coverage by 0.29%.
The diff coverage is 79.68%.

❗ Current head eb72536 differs from pull request most recent head f26f30b. Consider uploading reports for the commit f26f30b to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
- Coverage   87.63%   87.33%   -0.30%     
==========================================
  Files          77       78       +1     
  Lines        2418     2472      +54     
==========================================
+ Hits         2119     2159      +40     
- Misses        299      313      +14     
Impacted Files Coverage Δ
src/ProximalOperators.jl 67.74% <ø> (-1.01%) ⬇️
src/functions/TotalVariation1D.jl 79.68% <79.68%> (ø)
src/functions/indBallRank.jl 84.84% <0.00%> (-3.39%) ⬇️
src/functions/cubeNormL2.jl 89.47% <0.00%> (-0.53%) ⬇️
src/functions/indGraph.jl 86.20% <0.00%> (-0.46%) ⬇️
src/calculus/separableSum.jl 86.04% <0.00%> (-0.32%) ⬇️
src/functions/indHyperslab.jl 96.29% <0.00%> (-0.26%) ⬇️
src/functions/indGraphSkinny.jl 96.15% <0.00%> (-0.15%) ⬇️
src/functions/indGraphFat.jl 96.55% <0.00%> (-0.12%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ab5afa...f26f30b. Read the comment docs.

@fabian-sp
Copy link
Contributor Author

I added now a test for the optimality conditions. Worked for me for a couple of test cases, though the approximately equal to 0 assertion is a bit tricky. If you have any suggestions let me know.

Copy link
Member

@lostella lostella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I almost forgot: to be able to use this, you need to include the source file from the main package script: https://github.com/JuliaFirstOrder/ProximalOperators.jl/blob/master/src/ProximalOperators.jl this is why tests are currently failing (the new type cannot be used)

How big of an issue is the assertion on u[end]? Does it fall significantly away from zero? Maybe you could add some (non random) test cases where the problem occurs, to better look into it

src/functions/normTV.jl Outdated Show resolved Hide resolved
test/test_optimality_conditions.jl Show resolved Hide resolved
test/test_optimality_conditions.jl Outdated Show resolved Hide resolved
test/test_optimality_conditions.jl Outdated Show resolved Hide resolved
@lostella lostella linked an issue Aug 4, 2021 that may be closed by this pull request
Copy link
Member

@lostella lostella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, good job and thanks for translating the algorithm from the paper into a GOTO-free version, that must have been a bit of a puzzle!

It looks like the test cases are not covering many of the algorithm branches (at least according to codecov’s comments). This may be due to the fact that the test cases are very small or not particularly relevant for this algorithm (like in case y ends up being equal to x, or a constant vector). One way to come up with better ones might be to:

  • design a piecewise-constant signal, with a handful of change points, of large enough magnitude so that denoising doesn’t get rid of them
  • add small magnitude noise, that would be killed by denoising

This way one should be able to have fixed (non-random) test instances of small size.
To nail what “small vs large” magnitudes are, one can do trial and error or try to understand this from the optimality conditions or algorithm logic, whatever is easier.

Sorry for this further ask :-) but I think it’s worth having test cases that cover the algorithm properly. If I have time I’ll try to come up with some test cases too!

src/functions/TotalVariation1D.jl Outdated Show resolved Hide resolved
@fabian-sp
Copy link
Contributor Author

So I played around a bit and it seems that some of the if-clauses (the first two) are only for edge cases (which I havent found yet).
Something like
x = vcat(LinRange(1., -1., 10), -1*ones(3), LinRange(-1., 1., 10)) works okay as it runs through a couple of different clauses. But we will not get 100% coverage with that. I'll try a bit more.

@fabian-sp
Copy link
Contributor Author

@lostella I added the "pathological case" from section 2A in the paper. Together with the other test cases, I think almost every clause but the first is now covered. But I don't really know how to get the last one. Did you have any success?

@lostella
Copy link
Member

lostella commented Aug 6, 2021

Did you have any success?

Thanks! Didn’t get to it yet, but maybe it’s enough test cases already. I’ll let the tests run and if everything is green approve & merge

@lostella lostella merged commit 3729f66 into JuliaFirstOrder:master Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TV norm prox
2 participants