-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
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 |
There was a problem hiding this comment.
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!
)
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be removed
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove pls
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove pls
There was a problem hiding this comment.
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.
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...