YingfanWang/PaCMAP

Inconsistent gradient calculations

Closed this issue · 1 comments

When looking through the source code, I noticed that in pacmap_grad, there seems to be an inconsistency when calculating the gradients for the different pairs.

For nearest neighbor and mid-near pairs, the gradient calculation looks like

grad[i, d] += w1 * y_ij[d]
grad[j, d] -= w1 * y_ij[d]

but for further pairs, it's

grad[i, d] -= w1 * y_ij[d]
grad[j, d] += w1 * y_ij[d]

where you're subtracting for i and adding for j instead of the other way around. Is this a typo, or a legitimate change in the calculation?

It's a legitimate change. Further pairs are supposed to push points apart.