コード例 #1
0
 def forward(self, x: QTensor) -> torch.Tensor:
     """Computes the forward pass to convert a quaternion vector to a real vector"""
     if self.type == "sum":
         return x.r + x.i + x.j + x.k
     elif self.type == "mean":
         return (x.r + x.i + x.j + x.k).mean()
     elif self.type == "norm":
         return x.norm()
     else:
         x = torch.cat([x.r, x.i, x.j, x.k], dim=-1)
         return self.affine(x)
コード例 #2
0
def interaction(q: QTensor) -> torch.Tensor:
    norm = q.norm()
    c = norm.mean(dim=-1).unsqueeze(1)
    c = c.expand_as(norm)
    f = norm / torch.max(norm, c)
    return f