SimGRACE icon indicating copy to clipboard operation
SimGRACE copied to clipboard

关于alignment和uniformity?

Open githubXin123 opened this issue 3 years ago • 6 comments

作者您好。最近刚接触对比学习,您文章中有分析alignment和uniformity这两个指标,但我在代码部分没找到。不知道是我没找到,还是这部分是和模型分开单独计算、分析的?

githubXin123 avatar May 15 '22 07:05 githubXin123

您好,感谢您对我们工作的兴趣。我以伪代码的形式展示出我们是如何计算alignment和uniformity (该部分是我们单独计算、分析的):

# bsz : batch size (number of positive pairs)
# d   : latent dim
# x   : Tensor, shape=[bsz, d]
#       latents for one side of positive pairs
# y   : Tensor, shape=[bsz, d]
#       latents for the other side of positive pairs

def align_metric(x, y, alpha=2):
    return (x - y).norm(p=2, dim=1).pow(alpha).mean()

def uniform_metric(x, t=2):
    return torch.pdist(x, p=2).pow(2).mul(-t).exp().mean().log()

junxia97 avatar May 16 '22 00:05 junxia97

好的,谢谢。

githubXin123 avatar May 16 '22 00:05 githubXin123

您好,我想问下您代码中deepinformax.py文件是用来做什么的呢?

XuexiongLuoMQ avatar May 22 '22 08:05 XuexiongLuoMQ

您好,deepinformax.py文件只是对其他无监督图表征学习方法的复现。

junxia97 avatar May 22 '22 09:05 junxia97

你好,我想问下这个代码的环境是什么版本的呢?使用torch1.10+cu111不太行

mpanpan avatar Jun 22 '22 12:06 mpanpan

  • Python 3.7.4
  • PyTorch 1.7.0
  • torch_geometric 1.5.0 不同类别实验的具体配置不一样,你可以参考下每个文件夹下的readme文件

junxia97 avatar Jul 03 '22 08:07 junxia97