Precision,recall and f1 score values in EXP

I am using doing binary segmentation using Signet, IoU loss. the problem is Precision, recall and f1 score values become exp. kindly guide me if there is an issue with my loss function or there is any other issue.i have pasted the loss code below
Thank you


class IoULoss(nn.Module):
    def __init__(self, weight=None, size_average=True):
        super(IoULoss, self).__init__()

    def forward(self, inputs, targets, smooth=1):

        inputs = inputs.view(-1)
        targets = targets.view(-1)

        intersection = (inputs * targets).sum()
        total = (inputs + targets).sum()
        union = total - intersection 
        
        IoU = (intersection + smooth)/(union + smooth)
                
        return 1 - IoU

results

The result table indicates that the precision, recall, F1, and Ji are all zero. You can ignore the small numbers and basically treat them as zero values, so you should check your metric calculation as well as the results of your model.

If I stop and then resume the training everything works fine. I have used PyTorch anomaly detection and even tried to clip gradient between -5 to 5 but it’s also not working. but the problem is what can be the issue then

  1. Data does not contain any nan value.
  2. Changing the model does not work.
  3. Gradient clipping does not work.
  4. learning rate is 1e^-3 at the start of training and updating it using lr scheduler
  5. Apparently there is no issue in metric and loss calculation code.

then what can be the issue
kindly guide me

Any help will be appreciated
Thanks

I don’t see any NaNs in your output, so I’m unsure why you are checking for these invalid values.
In your table the scientific notation is used, which is indicating values close to zero.