I’ve forgotten to mention, that I took th.cdist() for the distance computation between cluster centers and data points (image patches) which is Dx-ci^dct in the following formula: -1/2h^2 * ||Dx - ci^dct||² . So you mean that I do not need to calculate the norm here in the formula with th.norm(x) where x = Dx - ci^dct because I already have the eucledian distances?