Hi,
Doing the weighting on the loss will definitely match the behavior of d(d_i,:,:,:) = kappa*d1 + (1-kappa)*d2; yes.
But there seem to be some renormalization happening here before the gradients are combined? I’m not sure I understand what it’s trying to do though.