Skip to content

Commit

Permalink
Add ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagandhamal committed Oct 1, 2022
1 parent 2d7466f commit e178f36
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion torchvision/ops/ciou_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,7 @@ def complete_box_iou_loss(
elif reduction == "sum":
loss = loss.sum()
else:
raise ValueError(f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'")
raise ValueError(
f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'"
)
return loss
4 changes: 3 additions & 1 deletion torchvision/ops/diou_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def distance_box_iou_loss(
elif reduction == "sum":
loss = loss.sum()
else:
raise ValueError(f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'")
raise ValueError(
f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'"
)
return loss


Expand Down
4 changes: 3 additions & 1 deletion torchvision/ops/focal_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def sigmoid_focal_loss(
# Check reduction option
modes = ["none", "mean", "sum"]
if reduction not in modes:
raise ValueError(f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'")
raise ValueError(
f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'"
)

if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(sigmoid_focal_loss)
Expand Down
4 changes: 3 additions & 1 deletion torchvision/ops/giou_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,7 @@ def generalized_box_iou_loss(
elif reduction == "sum":
loss = loss.sum()
else:
raise ValueError(f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'")
raise ValueError(
f"Invalid Value for arg 'reduction': '{reduction} \n Supported reduction modes: 'none', 'mean', 'sum'"
)
return loss

0 comments on commit e178f36

Please sign in to comment.