Skip to content

Instantly share code, notes, and snippets.

@SannaPersson
Created March 21, 2021 10:47
Show Gist options
  • Save SannaPersson/008f516f6885c8c97bba84f0a505f569 to your computer and use it in GitHub Desktop.
Save SannaPersson/008f516f6885c8c97bba84f0a505f569 to your computer and use it in GitHub Desktop.
anchors = anchors.reshape(1, 3, 1, 1, 2) # reshaping for broadcasting
box_preds = torch.cat([self.sigmoid(predictions[..., 1:3]), torch.exp(predictions[..., 3:5]) * anchors], dim=-1)
ious = intersection_over_union(box_preds[obj], target[..., 1:5][obj]).detach()
object_loss = self.bce((predictions[..., 0:1][obj]), (ious * target[..., 0:1][obj]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment