Closed epapoutsellis closed 4 months ago
I think @casperdcl will want a signature
if out is not None:
out.fill(grad)
return grad
Don't we have a problem with the subset
signature for CIL? gradient1(self, image, subset=-1, out=None)
. Maybe not as they're named arguments.
These can then easily be added to SIRF. @evgueni-ovtchinnikov, could you do that?
- Option 1: CIL algorithms with SIRF Objectives and Priors. This combination is for maximizing the -LogLikelihood. Therefore a positive step size in CIL algorithms (gradient descent) will not work. We need a negative step size.
I really don't like this. It works for some algorithms, but anything that uses line-searches, backtracking etc will get very confused.
- Option 2: CIL algorithms with CIL Objectives and SIRF Operators/Priors: In this case, instead of using the PoissonLogLikelihoodWithLinearModelForMean, we build one using KullbackLeibler with SIRF Operators and SIRF random events. The problem in this case is that the objective values of SIRF Objective and CIL Objective are different.
This is a constant offset. Why does it matter?
However, I predict that KL will be slower than the SIRF operator.
obj = cil.optimisation.functions.ScaledFunction(SIRFobj, -1)
I prefer to recommend the 3rd option. Obviously, it will be slower as well, as internally there will be an extra multiplication of the gradient (unless CIL is smart and first multiplies steps wtih any scalars, and only then the actual container), but it is entirely generic.
Resuming a conversation with @epapoutsellis @KrisThielemans @evgueni-ovtchinnikov @casperdcl :
Add out
parameter to the signature of gradient
of SIRF functions and priors. The method should return even if out
is passed:
if out is not None:
out.fill(grad)
return grad
PoissonLogLikelihoodWithLinearModelForMean vs KullbackLeibler. These differ by a constant offset which shouldn't impact the minimisation.
Using PoissonLogLikelihoodWithLinearModelForMean with SIRF object should be faster.
KullbackLeibler should be used with some algorithms such as PDHG, which requires methods convex_conjugate
etc that are missing in SIRF objective functions.
Whenever SIRF Objective functions and priors are used in CIL algorithms, they should be wrapped by a CIL ScaledFunction
with a scalar = -1
At the moment, we cannot use CIL algorithms with SIRF Objectives and Priors (smooth optimisation). The reason is that there are no
out
arguments in ObjectiveFunction and PriorIf we do sth like
then we are ok.
Now, there are options for PET/SPECT applications using CIL + SIRF:
Option 2: CIL algorithms with CIL Objectives and SIRF Operators/Priors: In this case, instead of using the PoissonLogLikelihoodWithLinearModelForMean, we build one using KullbackLeibler with SIRF Operators and SIRF random events. The problem in this case is that the objective values of SIRF Objective and CIL Objective are different.
$$KL_{CIL}(b, Au) = \int b\log(b) - b\log(Au+\eta) - b + Au + \eta$$
$$KL_{SIRF}(b, Au) = - \int Au + \eta - g\log(Au+\eta) $$
Related to https://github.com/TomographicImaging/CIL/discussions/1516