SIRF icon indicating copy to clipboard operation
SIRF copied to clipboard

Integer valued sirf.ObjectiveFunction.value

Open Imraj-Singh opened this issue 2 years ago • 8 comments

I am reconstructing with SIRF and have only encountered integer values for sirf.ObjectiveFunction.value.

Is this expected behaviour? I could be doing something wrong, but I am not sure I am... I had a look at how it is exposed in SIRF and it seems that a float type is used, but all my values are in the format "1234567.0" with the values after the decimal non-existent...

Help would be appreciated!

Imraj-Singh avatar Jan 23 '23 11:01 Imraj-Singh

this is obviously a bit strange, but floats do have limited precision, and there could be some printing stuff going on.

Note that STIR uses doubles for the objective function, so if SIRF uses floats, we'd loose some precision there.

KrisThielemans avatar Jan 23 '23 12:01 KrisThielemans

I have managed to reproduce this problem in the ML_reconstruction.ipynb notebook in the pet SIRF-Exercises.

For the acquired_data in the notebook I multiply by an arbitrary value i.e. "100000"

image

In the reconstruction I print the objective function value:

image

As you can see there is a problem with precision it seems. I am a bit worried if the could affect gradients etc?

Imraj-Singh avatar Jan 23 '23 14:01 Imraj-Singh

As you can see there is a problem with precision it seems.

Do I?

Yes, the increment is small. there's a large (and in a sense arbitrary) offset to the KL. @robbietuk created an issue https://github.com/UCL/STIR/issues/697 on the offset and had a PR but ran out of steam https://github.com/UCL/STIR/pull/760.

I am a bit worried if the could affect gradients etc?

the computation of the gradient is independent of the computation of the value. The latter is much more sensitive to numerical problems. (Adding lots of numbers with limited precision is tricky).

Do check if SIRF uses doubles.

KrisThielemans avatar Jan 23 '23 14:01 KrisThielemans

If you multiply by 1000 do you get the same effect of everything after the decimal point being zero? In that case we know it is wrong because we have seen there are more significant figures.

DANAJK avatar Jan 25 '23 09:01 DANAJK

what's the status here please?

KrisThielemans avatar Nov 24 '23 10:11 KrisThielemans

@Imraj-Singh this one is a bit urgent. Can you clarify if we need to fix anything?

KrisThielemans avatar May 29 '24 15:05 KrisThielemans

@KrisThielemans I am not sure if the precision loss due to the KL offset will have meaningful ramifications for assessing convergence etc? I did quickly look at the source and it seems that the STIR value is cast to float in SIRF: https://github.com/SyneRBI/SIRF/blob/6c7259d1e37f6112610619883c385325b2998c63/src/xSTIR/cSTIR/cstir.cpp#L1152

Imraj-Singh avatar May 31 '24 08:05 Imraj-Singh

Fixed now - see #1264. @Imraj-Singh Please try again.

evgueni-ovtchinnikov avatar Jun 21 '24 10:06 evgueni-ovtchinnikov