I am trying to implement the Homoscedastic uncertainty loss from Geometric Loss Functions for Camera Pose Regression with Deep Learning.

```
class HomoLoss(nn.Module):
def __init__(self):
super(HomoLoss, self).__init__()
self.sx = nn.Parameter(torch.tensor(0.0))
self.sq = nn.Parameter(torch.tensor(-3.5))
self.criterion = nn.MSELoss(reduction = 'mean')
def forward(self, out, gt):
rot_loss = self.criterion(out[:, 3:], gt[:, 3:])
trans_loss = self.criterion(out[:, :3], gt[:, :3])
loss = self.learned_loss(trans_loss, rot_loss)
#print("SX: {} and SQ: {} values are".format(self.sx, self.sq))
return loss
def learned_loss(self, trans_loss, rot_loss):
return (-1*self.sx).exp()*trans_loss + self.sx + (-1*self.sq).exp()*rot_loss + self.sq
```

is this the correct way to implement and my loss is always in negative, is it behaving as properly?

Any leads would be appreciated !!!