Unverified Commit d0ab8a8d authored by Gao, Xiang's avatar Gao, Xiang Committed by GitHub
Browse files

Use handwritten cosine similarity (#520)

parent ca6e325b
......@@ -66,10 +66,9 @@ def angular_terms(Rca: float, ShfZ: Tensor, EtaA: Tensor, Zeta: Tensor,
vectors12 = vectors12.unsqueeze(-1).unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
distances12 = vectors12.norm(2, dim=-5)
# 0.95 is multiplied to the cos values to prevent acos from
# returning NaN.
cos_angles = 0.95 * torch.nn.functional.cosine_similarity(vectors12[0], vectors12[1], dim=-5)
angles = torch.acos(cos_angles)
cos_angles = vectors12.prod(0).sum(1) / distances12.prod(0)
# 0.95 is multiplied to the cos values to prevent acos from returning NaN.
angles = torch.acos(0.95 * cos_angles)
fcj12 = cutoff_cosine(distances12, Rca)
factor1 = ((1 + torch.cos(angles - ShfZ)) / 2) ** Zeta
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment