This PR proposes a fix for the adjacency matrix construction.
I noticed that the learned adjacency matrices look unnatural, with most edges coming out of the first ~50% of the nodes (as per their arbitrary ID). See this example:
I have traced this issue back to the combination of torch.topk and tanh. The tanh squashing leads to many entries being (numerically) tied at the maximum possible value of 1.0. In the case of ties, torch.topk always selects the firstK tied entries. This leads to the issue in the image above. By adding just a tiny bit amount of random noise, this PR fixes this bias, leading to more "natural" adjacency matrices like this here:
This PR proposes a fix for the adjacency matrix construction.
I noticed that the learned adjacency matrices look unnatural, with most edges coming out of the first ~50% of the nodes (as per their arbitrary ID). See this example:
I have traced this issue back to the combination of
torch.topk
andtanh
. Thetanh
squashing leads to many entries being (numerically) tied at the maximum possible value of1.0
. In the case of ties,torch.topk
always selects the firstK
tied entries. This leads to the issue in the image above. By adding just a tiny bit amount of random noise, this PR fixes this bias, leading to more "natural" adjacency matrices like this here: