def forward(self, x, y): x, y = torch.distributions.utils.broadcast_all(x, y) x, unflatten = util.flatten_batch(x, 1) y, _ = util.flatten_batch(y, 1) output = self.net(torch.abs(x - y)) return unflatten(output)
def forward(self, x, y): x, y = torch.distributions.utils.broadcast_all(x, y) x, unflatten = util.flatten_batch(x, 1) y, _ = util.flatten_batch(y, 1) output = -torch.mean(torch.abs(x - y), dim=-1, keepdim=True) output = self.adjust(output) return unflatten(output)
def forward(self, x, y): x, y = torch.distributions.utils.broadcast_all(x, y) x, unflatten = util.flatten_batch(x, 1) y, _ = util.flatten_batch(y, 1) xy = torch.sum(x * y, dim=-1, keepdim=True) xx = torch.sum(x**2, dim=-1, keepdim=True) yy = torch.sum(y**2, dim=-1, keepdim=True) eps = 1e-3 output = xy / (torch.sqrt(xx) * torch.sqrt(yy) + eps) output = self.adjust(output) return unflatten(output)