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

added anscombe and tests and changed initial scaling #20

Closed
wants to merge 1 commit into from
Closed

added anscombe and tests and changed initial scaling #20

wants to merge 1 commit into from

Conversation

RainerHeintzmann
Copy link
Contributor

this adds the anscombe transform. I am not entirely happy with the way that the persisitent memory is dealt with by trapping the first call to the function within the deconv iterations...

CallCounter = 0;
sqrt_meas_b = 0;
function call_brancher(μ, meas, storage=copy(µ)) # uses a closure to deal with possibly normalized measurement data.
if CallCounter == 0
Copy link
Owner

Choose a reason for hiding this comment

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

Call Counter can be removed since Optim.jl takes track of how often the functions are called (fg!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The role of the CallCounter is to ensure that the sqrt(measured + b) is calculated only once. However this is hacky and dangerous! I would prefer a different mechanism, but this means that the core of DeonvOptim needs a larger change.

@@ -1,7 +1,8 @@
export Poisson, poisson_aux
export Gauss, gauss_aux
export ScaledGauss, scaled_gauss_aux

export Anscombe, anscombe_aux
using Tullio
Copy link
Owner

Choose a reason for hiding this comment

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

can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

end
storage .= abs2.(sqrt_meas_b .- sqrt.(μ .+ b))
return sum(storage)
#@tullio s = @inbounds abs2(sqrt_meas_b[i] - sqrt(μ[i] + b))
Copy link
Owner

Choose a reason for hiding this comment

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

can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

? you mean only the commented tullio line, I guess? Yes, but I prefer to keep it since this is what the future should eventually do, if tullio runs properly with Cuda.

function ChainRulesCore.rrule(::typeof(anscombe_aux), μ, meas, storage=copy(μ); b=1, sqrt_meas_b=0)
Y = anscombe_aux(μ, meas, storage; b=b, sqrt_meas_b=sqrt_meas_b)
function anscombe_aux_pullback(xbar)
# @show xbar
Copy link
Owner

Choose a reason for hiding this comment

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

remove pls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the comment with the show. Yes. remove

Y = anscombe_aux(μ, meas, storage; b=b, sqrt_meas_b=sqrt_meas_b)
function anscombe_aux_pullback(xbar)
# @show xbar
# @tullio storage[i] = @inbounds (one(eltype(μ)) - sqrt_meas_b[i] / sqrt(μ[i] + b)) # xbar[i]
Copy link
Owner

Choose a reason for hiding this comment

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

remove pls

Copy link
Contributor Author

Choose a reason for hiding this comment

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

show yes, tullio I prefer to keep.

@roflmaostc roflmaostc closed this Jul 4, 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.

2 participants