generalized_box_iou_loss¶
- torchvision.ops.generalized_box_iou_loss(boxes1: Tensor, boxes2: Tensor, reduction: str = 'none', eps: float = 1e-07) Tensor[source]¶
對梯度友好的 IoU 損失,增加了一個額外的懲罰項,該懲罰項在邊界框不重疊時非零,並且隨著最小外接框的大小而縮放。此損失函式是對稱的,因此 boxes1 和 boxes2 引數可以互換。
兩組邊界框都期望採用
(x1, y1, x2, y2)格式,其中0 <= x1 < x2和0 <= y1 < y2,並且兩個邊界框應具有相同的維度。- 引數:
boxes1 (Tensor[N, 4] 或 Tensor[4]) – 第一組邊界框
boxes2 (Tensor[N, 4] 或 Tensor[4]) – 第二組邊界框
reduction (string, optional) – 指定應用於輸出的歸約方式:
'none'|'mean'|'sum'。'none': 不對輸出應用歸約。'mean': 對輸出取平均值。'sum': 對輸出求和。預設值:'none'eps (float) – 防止除以零的小數。預設值: 1e-7
- 返回:
應用了歸約選項的損失張量。
- 返回型別:
Tensor
- 參考
Hamid Rezatofighi 等人: Generalized Intersection over Union: A Metric and A Loss for Bounding Box Regression: https://arxiv.org/abs/1902.09630