239 lines
8.2 KiB
Markdown
239 lines
8.2 KiB
Markdown
|
|
# Dice Loss指标说明 - 重要!
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ⚠️ 关键理解
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
Dice Loss vs Dice Coefficient
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
|
|||
|
|
Dice Loss (训练中显示的指标):
|
|||
|
|
- 这是损失函数
|
|||
|
|
- 越低越好 ✅ (like all losses)
|
|||
|
|
- 数值范围: 0-1
|
|||
|
|
|
|||
|
|
Dice Coefficient (评估指标):
|
|||
|
|
- 这是相似度/IoU指标
|
|||
|
|
- 越高越好 ✅
|
|||
|
|
- 数值范围: 0-1
|
|||
|
|
|
|||
|
|
关系:
|
|||
|
|
Dice Loss = 1 - Dice Coefficient
|
|||
|
|
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📊 您看到的数值解释
|
|||
|
|
|
|||
|
|
### Divider性能变化
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
════════════════════════════════════════════════════════════════
|
|||
|
|
|
|||
|
|
指标: Divider Dice Loss
|
|||
|
|
|
|||
|
|
Epoch 5基线: 0.525
|
|||
|
|
Epoch 20预期: 0.420
|
|||
|
|
变化: -0.105 (降低了20%)
|
|||
|
|
|
|||
|
|
解释:
|
|||
|
|
✅ Dice Loss降低 = 性能变好!
|
|||
|
|
✅ 这是我们的目标
|
|||
|
|
✅ -20%意味着改善20%
|
|||
|
|
|
|||
|
|
════════════════════════════════════════════════════════════════
|
|||
|
|
|
|||
|
|
转换为Dice Coefficient (相似度):
|
|||
|
|
|
|||
|
|
Epoch 5: Dice Coef = 1 - 0.525 = 0.475 (47.5%相似度)
|
|||
|
|
Epoch 20: Dice Coef = 1 - 0.420 = 0.580 (58.0%相似度)
|
|||
|
|
|
|||
|
|
改善: 0.580 - 0.475 = 0.105
|
|||
|
|
提升: 22% (相对提升)
|
|||
|
|
|
|||
|
|
════════════════════════════════════════════════════════════════
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📈 性能改善可视化
|
|||
|
|
|
|||
|
|
### Dice Loss (越低越好)
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
1.0 ┤
|
|||
|
|
│
|
|||
|
|
0.8 ┤
|
|||
|
|
│
|
|||
|
|
0.6 ┤
|
|||
|
|
│ Baseline ─┐
|
|||
|
|
0.5 ┤━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|||
|
|
│ 0.525
|
|||
|
|
0.4 ┤ Task-GCA ─┐
|
|||
|
|
│━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
|
|||
|
|
│ 0.420 ✅ 更好
|
|||
|
|
0.2 ┤
|
|||
|
|
│
|
|||
|
|
0.0 ┤ ← 理想值 (完美分割)
|
|||
|
|
└────────────────────────────────────────────→
|
|||
|
|
|
|||
|
|
越低越好 ↓
|
|||
|
|
0.525 → 0.420 是改善 ✅
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
### Dice Coefficient (越高越好)
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
1.0 ┤ ← 理想值 (完美分割)
|
|||
|
|
│
|
|||
|
|
0.8 ┤
|
|||
|
|
│
|
|||
|
|
0.6 ┤ Task-GCA ─┐
|
|||
|
|
│ ┌━━━━━━━━━━━━━━━━┛
|
|||
|
|
│ │ 0.580 ✅ 更好
|
|||
|
|
0.4 ┤ Baseline ─┤
|
|||
|
|
│ ┌━━━━━━━━━━━━━━━┛
|
|||
|
|
│ │ 0.475
|
|||
|
|
0.2 ┤ │
|
|||
|
|
│
|
|||
|
|
0.0 ┤
|
|||
|
|
└────────────────────────────────────────────→
|
|||
|
|
|
|||
|
|
越高越好 ↑
|
|||
|
|
0.475 → 0.580 是改善 ✅
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🎯 所有分割类别的改善
|
|||
|
|
|
|||
|
|
### 训练日志中的Dice Loss (越低越好)
|
|||
|
|
|
|||
|
|
| 类别 | Epoch 5 | Epoch 20目标 | 改善 | 说明 |
|
|||
|
|
|------|---------|-------------|------|------|
|
|||
|
|
| **drivable_area** | 0.110 | 0.075 | ↓ -32% | ✅ 变好 |
|
|||
|
|
| **ped_crossing** | 0.240 | 0.170 | ↓ -29% | ✅ 变好 |
|
|||
|
|
| **walkway** | 0.225 | 0.150 | ↓ -33% | ✅ 变好 |
|
|||
|
|
| **stop_line** | 0.345 | 0.245 | ↓ -29% | ✅ 变好 |
|
|||
|
|
| **carpark_area** | 0.205 | 0.140 | ↓ -32% | ✅ 变好 |
|
|||
|
|
| **divider** | 0.525 | 0.420 | ↓ -20% | ✅ 变好 ⭐ |
|
|||
|
|
|
|||
|
|
**所有的负数变化都是改善!** ✅
|
|||
|
|
|
|||
|
|
### 转换为IoU指标 (越高越好)
|
|||
|
|
|
|||
|
|
| 类别 | Epoch 5 IoU | Epoch 20 IoU | 改善 |
|
|||
|
|
|------|------------|-------------|------|
|
|||
|
|
| **drivable_area** | 0.890 | 0.925 | ↑ +3.9% |
|
|||
|
|
| **ped_crossing** | 0.760 | 0.830 | ↑ +9.2% |
|
|||
|
|
| **walkway** | 0.775 | 0.850 | ↑ +9.7% |
|
|||
|
|
| **stop_line** | 0.655 | 0.755 | ↑ +15.3% |
|
|||
|
|
| **carpark_area** | 0.795 | 0.860 | ↑ +8.2% |
|
|||
|
|
| **divider** | 0.475 | 0.580 | ↑ +22.1% ⭐ |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 📊 检测性能 (也是越低越好的Loss)
|
|||
|
|
|
|||
|
|
| 指标 | Epoch 5 | Epoch 20目标 | 改善 |
|
|||
|
|
|------|---------|-------------|------|
|
|||
|
|
| **Heatmap Loss** | 0.240 | 0.220 | ↓ -8.3% ✅ 变好 |
|
|||
|
|
| **BBox Loss** | 0.310 | 0.285 | ↓ -8.1% ✅ 变好 |
|
|||
|
|
| **Classification Loss** | 0.036 | 0.033 | ↓ -8.3% ✅ 变好 |
|
|||
|
|
|
|||
|
|
转换为评估指标:
|
|||
|
|
| **mAP** (越高越好) | ~0.68 | ~0.70 | ↑ +2.9% ✅ |
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 💡 记忆规则
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
训练日志中的指标:
|
|||
|
|
|
|||
|
|
✅ Loss类指标 (Dice Loss, Focal Loss, Heatmap Loss...):
|
|||
|
|
→ 越低越好
|
|||
|
|
→ 下降是改善
|
|||
|
|
→ 负百分比是进步
|
|||
|
|
|
|||
|
|
✅ IoU类指标 (matched_ious):
|
|||
|
|
→ 越高越好
|
|||
|
|
→ 上升是改善
|
|||
|
|
→ 正百分比是进步
|
|||
|
|
|
|||
|
|
✅ mAP, mIoU (评估时):
|
|||
|
|
→ 越高越好
|
|||
|
|
→ 上升是改善
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## 🎯 Task-specific GCA的预期改善
|
|||
|
|
|
|||
|
|
### 完整预期表 (正确理解)
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
分割性能 (Dice Loss - 越低越好)
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
|
|||
|
|
类别 Epoch 5 → Epoch 20 改善 说明
|
|||
|
|
─────────────────────────────────────────────────────────────────
|
|||
|
|
drivable_area 0.110 → 0.075 -32% ✅ 大幅改善
|
|||
|
|
ped_crossing 0.240 → 0.170 -29% ✅ 大幅改善
|
|||
|
|
walkway 0.225 → 0.150 -33% ✅ 大幅改善
|
|||
|
|
stop_line 0.345 → 0.245 -29% ✅ 大幅改善
|
|||
|
|
carpark_area 0.205 → 0.140 -32% ✅ 大幅改善
|
|||
|
|
divider ⭐ 0.525 → 0.420 -20% ✅ 显著改善
|
|||
|
|
|
|||
|
|
Overall mIoU 0.550 → 0.612 +11% ✅ 大幅提升
|
|||
|
|
(越高越好)
|
|||
|
|
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
检测性能 (Loss - 越低越好)
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
|
|||
|
|
指标 Epoch 5 → Epoch 20 改善 说明
|
|||
|
|
─────────────────────────────────────────────────────────────────
|
|||
|
|
Heatmap Loss 0.240 → 0.220 -8% ✅ 改善
|
|||
|
|
BBox Loss 0.310 → 0.285 -8% ✅ 改善
|
|||
|
|
|
|||
|
|
mAP (越高越好) 0.680 → 0.695 +2.2% ✅ 提升
|
|||
|
|
|
|||
|
|
═══════════════════════════════════════════════════════════════════
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
## ✅ 总结
|
|||
|
|
|
|||
|
|
```
|
|||
|
|
问题: Divider Dice 0.525 → 0.420 是变差了吗?
|
|||
|
|
|
|||
|
|
答案: ❌ 不是!这是变好了!✅✅✅
|
|||
|
|
|
|||
|
|
原因:
|
|||
|
|
- Dice Loss 是损失函数
|
|||
|
|
- 损失降低 = 性能提升
|
|||
|
|
- 0.525 → 0.420 降低了20%
|
|||
|
|
- 这意味着预测更准确了!
|
|||
|
|
|
|||
|
|
类比:
|
|||
|
|
- 就像错误率从52.5%降到42%
|
|||
|
|
- 或者考试错题从52.5道减少到42道
|
|||
|
|
- 当然是变好了!
|
|||
|
|
|
|||
|
|
Dice Coefficient视角:
|
|||
|
|
- 从47.5%相似度提升到58.0%相似度
|
|||
|
|
- 提升了22%
|
|||
|
|
- 这样更直观理解
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
|
|||
|
|
**🎉 所有负数改善都是好事!Divider从0.525降到0.420是显著改善!** ✅
|