Hi,
Unfortunately the linked code and the smoothing factor does not help much either, as for a patch where all I have are background the tflat.sum() would be 0. This would make intersection 0 as well, thus for majority of my patches or blocks I will get a return of 1.
So now rather than getting a very high loss I am getting a consistent loss of 1 for almost all patches.
This is strange that people have solved similar situations with dice loss but its not working for me.