Skip to content

Commit

Permalink
CIOULoss not NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
VCasecnikovs committed Dec 18, 2020
1 parent 0653ac5 commit c884ef8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def calculate_repullsion(self, y, y_hat):
RepBoxes.append(RepBox)
return torch.stack(RepGTS).mean(), torch.stack(RepBoxes).mean()

def forward(self, x, targets=None):
def forward(self, x : torch.Tensor, targets=None):
# Tensors for cuda support
FloatTensor = torch.cuda.FloatTensor if x.is_cuda else torch.FloatTensor

Expand Down Expand Up @@ -1070,7 +1070,10 @@ def forward(self, x, targets=None):
S = 1 - iou_masked
alpha = v / (S + v + 1e-7)

CIoUloss = (1 - iou_masked + rDIoU + alpha * v).sum(0)/num_samples
if num_samples != 0:
CIoUloss = (1 - iou_masked + rDIoU + alpha * v).sum(0)/num_samples
else:
CIoUloss = 0
# print(torch.isnan(pred_conf).sum())

loss_conf_noobj = F.binary_cross_entropy(pred_conf[noobj_mask], tconf[noobj_mask])
Expand Down

0 comments on commit c884ef8

Please sign in to comment.