Closed yaolu-zjut closed 2 years ago
Hello, I wonder that whether the code 'KH = K - K.mean(0, keepdim=True)' is right? I think it should be 'KH = K - K.mean(1, keepdim=True)'
x =torch.Tensor([[1,2,1,2],[2,3,1,2],[2,4,1,1],[3,4,1,4]]) unit = torch.ones([4, 4]) I = torch.eye(4) H = I - unit / 4 truth = torch.mm(x, H) you = x - x.mean(0, keepdim=True) my = x - x.mean(1, keepdim=True) print(you-truth) print(my-truth)
tensor([[-0.5000, -1.7500, 0.5000, -0.7500], [ 0.0000, -1.2500, 1.0000, -0.2500], [ 0.0000, -1.2500, 1.0000, -0.2500], [ 1.0000, -0.2500, 2.0000, 0.7500]]) tensor([[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.]])
@yaolu-zjut
Hi, thanks for your interest in my paper :)
KH
is a typo. It should be HK
.
However, my code is correct in terms of the HSIC implementation.
Note that trace(KHLH) = trace(HKHL)
because trace is invariant to a cyclic permutation.
https://math.stackexchange.com/questions/1474812/how-to-prove-the-cyclic-property-of-the-trace
Also, I'd like to suggest using the unbiased estimator instead of the biased estimator.
The default estimator is the unbiased one (algorithm='unbiased'
)
https://github.com/clovaai/rebias/blob/master/criterions/hsic.py#L42
Closing the issue, assuming the answer resolves the problem. Please re-open the issue as necessary.
Hello, I wonder that whether the code 'KH = K - K.mean(0, keepdim=True)' is right? I think it should be 'KH = K - K.mean(1, keepdim=True)'