land-cover icon indicating copy to clipboard operation
land-cover copied to clipboard

Calculation of variance in the super resolution loss

Open SorourMo opened this issue 3 years ago • 0 comments

Hi,

I have a question about variance in sr_loss. Could you please elaborate on why variance is calculated this way?

# Mean var of predicted distribution:

        var = K.sum(masked_probs * (1.0 - masked_probs), axis=(1, 2)) / (
            c_mask_size * c_mask_size
        )  # (16x5) / (16,1) --> shape 16x5`

Basically, in the above line, we calculate sigma(x(1-x)) / (n^2). However, since we had calculated mean (mu) in the previous line, we could use mu in the calculation of variance.

Definition of variance is sigma((x-mu)^2) / n. So I was thinking something like below: mean = K.sum(masked_probs, axis=(1, 2)) / c_mask_size # (16x5) / (16,1) --> shape 16x5 var = K.sum((K.pow(masked_probs - mean, 2) * c_mask), axis=(1, 2)) / ( c_mask_size ) # (16x5) / (16,1) --> shape 16x5 In the above line, * c_mask sets to zero the irrelevant values outside the current class's mask.

So why not stick to the exact variance formula here? Am I missing something?

Thanks,

SorourMo avatar Jul 29 '21 15:07 SorourMo