nawta commited on
Commit
8984678
·
verified ·
1 Parent(s): 4cd679d

Add exp004/exp005/exp006 weights, submissions, configs, docs, and logs

Browse files
Files changed (39) hide show
  1. README.md +131 -0
  2. configs/exp004/000.yaml +31 -0
  3. configs/exp004/001.yaml +36 -0
  4. configs/exp004/config.yaml +14 -0
  5. configs/exp005/000.yaml +43 -0
  6. configs/exp005/config.yaml +14 -0
  7. configs/exp006/000.yaml +31 -0
  8. configs/exp006/001.yaml +36 -0
  9. configs/exp006/config.yaml +14 -0
  10. configs/exp007/000.yaml +45 -0
  11. configs/exp007/001.yaml +46 -0
  12. configs/exp007/002.yaml +46 -0
  13. configs/exp007/config.yaml +14 -0
  14. docs/KAGGLE_DIRECTION.md +123 -0
  15. docs/TODO.md +94 -0
  16. docs/experiments.md +334 -0
  17. logs/Log_2025-02-10.md +24 -0
  18. logs/Log_2026-02-10.md +206 -0
  19. logs/Log_2026-02-11.md +205 -0
  20. logs/Log_2026-02-12.md +206 -0
  21. logs/Log_2026-02-16.md +89 -0
  22. submissions/exp004/000/submission.csv +0 -0
  23. submissions/exp004/000/submission_baseline.csv +0 -0
  24. submissions/exp004/000/submission_optimal_blend.csv +0 -0
  25. submissions/exp004/000/submission_rerank.csv +0 -0
  26. submissions/exp004/000/submission_tta.csv +0 -0
  27. submissions/exp005/000/submission.csv +0 -0
  28. submissions/exp005/000/submission_baseline.csv +0 -0
  29. submissions/exp005/000/submission_optimal_blend.csv +0 -0
  30. submissions/exp005/000/submission_rerank.csv +0 -0
  31. submissions/exp005/000/submission_tta.csv +0 -0
  32. submissions/exp006/001/submission.csv +0 -0
  33. submissions/exp006/001/submission_baseline.csv +0 -0
  34. submissions/exp006/001/submission_optimal_blend.csv +0 -0
  35. submissions/exp006/001/submission_rerank.csv +0 -0
  36. submissions/exp006/001/submission_tta.csv +0 -0
  37. weights/exp004_0938_optimal_blending/000/best_model.pth +3 -0
  38. weights/exp005_pseudo_labeling/000/best_model_finetuned.pth +3 -0
  39. weights/exp006_dinov2/001/best_model.pth +3 -0
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ tags:
4
+ - kaggle
5
+ - image-retrieval
6
+ - re-identification
7
+ - jaguar
8
+ - eva02
9
+ - dinov2
10
+ - arcface
11
+ ---
12
+
13
+ # Jaguar Re-Identification - Model Artifacts
14
+
15
+ Kaggle "[Jaguar Re-Identification Challenge](https://www.kaggle.com/competitions/jaguar-re-id)" コンペティションの学習済みモデル重み・サブミッション・設定ファイルのバックアップ。
16
+
17
+ ## Best Score
18
+
19
+ **Public LB 0.948** (exp004 + exp005 weighted ensemble, w=0.7/0.3)
20
+
21
+ ## Contents
22
+
23
+ ### Model Weights (`weights/`)
24
+
25
+ | Experiment | Description | LB Score | File | Size |
26
+ |------------|-------------|----------|------|------|
27
+ | exp004/000 | EVA-02-L-448 + GeM + ArcFace + Jaccard Rerank + Optimal Blend (10ep) | **0.946** | `weights/exp004_0938_optimal_blending/000/best_model.pth` | ~1.2GB |
28
+ | exp005/000 | Pseudo-Labeling fine-tune on exp004 (5ep) | 0.937 | `weights/exp005_pseudo_labeling/000/best_model_finetuned.pth` | ~1.2GB |
29
+ | exp006/001 | DINOv2 ViT-L-518 + GeM + ArcFace (20ep) | 0.925 | `weights/exp006_dinov2/001/best_model.pth` | ~1.2GB |
30
+
31
+ ### Submissions (`submissions/`)
32
+
33
+ 各実験の推論結果 CSV (baseline, TTA, rerank, optimal_blend)。
34
+
35
+ ### Configs (`configs/`)
36
+
37
+ 各実験の Hydra 設定ファイル (config.yaml + exp/*.yaml)。
38
+
39
+ ### Docs & Logs (`docs/`, `logs/`)
40
+
41
+ - `docs/experiments.md`: 全実験結果・知見集約
42
+ - `docs/TODO.md`: タスク管理
43
+ - `docs/KAGGLE_DIRECTION.md`: コンペ固有ワークフロー
44
+ - `logs/Log_*.md`: 日別開発ログ
45
+
46
+ ## Experiment Summary
47
+
48
+ | Experiment | Backbone | Epochs | Best Loss | Accuracy | LB |
49
+ |------------|----------|--------|-----------|----------|----|
50
+ | exp002/000 | MegaDescriptor-B-224 | 25 | - | - | 0.781 |
51
+ | exp003/000 | EVA-02-L-448 | 10 | - | - | 0.921 |
52
+ | exp003/001 | EVA-02-L-448 | 20 | 0.3035 | 96.78% | 0.913 |
53
+ | **exp004/000** | **EVA-02-L-448** | **10** | **0.1355** | **98.47%** | **0.946** |
54
+ | exp004/001 | EVA-02-L-448 | 20 | 0.0481 | 99.42% | 0.945 |
55
+ | exp005/000 | EVA-02-L-448 (PL) | 5 | 0.0731 | 99.20% | 0.937 |
56
+ | exp006/000 | DINOv2-L-518 | 10 | 0.3982 | 95.14% | 0.897 |
57
+ | exp006/001 | DINOv2-L-518 | 20 | 0.0827 | 98.94% | 0.925 |
58
+ | exp007/000 | EVA-02-L-448 (LwLR+W+EMA) | 10 | 4.4556 | 48.94% | - |
59
+ | exp007/001 | EVA-02-L-448 (LwLR0.95+W+EMA) | 10 | 0.3466 | 95.56% | - |
60
+ | exp007/002 | EVA-02-L-448 (W+EMA) | 10 | 0.1904 | 97.83% | - |
61
+ | **Ensemble** | **exp004+exp005 (w0.7/0.3)** | - | - | - | **0.948** |
62
+
63
+ ## Key Insights
64
+
65
+ - **EVA-02 Large 448px** が最も効果的なバックボーン (MegaDescriptor-B-224 比 LB +0.140)
66
+ - **Jaccard Re-ranking + Optimal Blending** (20% raw + 80% reranked) が後処理として有効
67
+ - **20ep 延長学習は微小改善〜悪化**: exp003は悪化 (0.921→0.913)、exp004はほぼ同等 (0.946→0.945)
68
+ - **Layer-wise LR Decay は EVA-02 Large に有害**: decay_rate=0.95 でも全層同一LR に劣る
69
+ - **Warmup + EMA は微小劣化**: 10ep では warmup の序盤学習遅延を回収しきれない
70
+
71
+ ## Reproduction
72
+
73
+ ### Code
74
+
75
+ ```bash
76
+ git clone git@github.com:nawta/Jaguar_Re_Identification.git
77
+ cd Jaguar_Re_Identification
78
+ git checkout lb-0.948
79
+ ```
80
+
81
+ ### Environment
82
+
83
+ ```bash
84
+ # Python environment
85
+ uv sync
86
+
87
+ # or Docker
88
+ make build && make bash
89
+ ```
90
+
91
+ ### Data
92
+
93
+ Competition data is NOT included. Download from Kaggle:
94
+
95
+ ```bash
96
+ kaggle competitions download -c jaguar-re-id
97
+ unzip jaguar-re-id.zip -d input/
98
+ ```
99
+
100
+ ### Training
101
+
102
+ ```bash
103
+ # Best single model (exp004)
104
+ uv run python -m experiments.exp004_0938_optimal_blending.run exp=000
105
+
106
+ # Pseudo-labeling (exp005, requires exp004 weights)
107
+ uv run python -m experiments.exp005_pseudo_labeling.run exp=000
108
+
109
+ # DINOv2 (exp006)
110
+ uv run python -m experiments.exp006_dinov2.run exp=000
111
+ ```
112
+
113
+ ### Ensemble (LB 0.948)
114
+
115
+ exp004 と exp005 の submission.csv を weighted average (w=0.7/0.3) で結合:
116
+
117
+ ```python
118
+ import pandas as pd
119
+ df004 = pd.read_csv("output/experiments/exp004_0938_optimal_blending/000/submission.csv")
120
+ df005 = pd.read_csv("output/experiments/exp005_pseudo_labeling/000/submission.csv")
121
+ df_ens = df004.copy()
122
+ df_ens["score"] = 0.7 * df004["score"] + 0.3 * df005["score"]
123
+ df_ens.to_csv("submission_ensemble.csv", index=False)
124
+ ```
125
+
126
+ ## Not Included
127
+
128
+ - **Competition input data** (`input/`, ~17GB): Re-download via `kaggle competitions download -c jaguar-re-id`
129
+ - **Inferior model weights**: exp002 (LB 0.781), exp003 (LB 0.921), exp007 (exp004 以下)
130
+ - **Python virtual environment** (`.venv/`): Recreate via `uv sync`
131
+ - **wandb logs**: Synced to [wandb.ai/nawta1998/jaguar-re-identification](https://wandb.ai/nawta1998/jaguar-re-identification)
configs/exp004/000.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # 0.938 ノートブック設定 (EVA-02 Large, FC層なし, Jaccard re-ranking)
5
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
6
+ image_size: 448
7
+ num_classes: 31
8
+
9
+ epochs: 10
10
+ batch_size: 4
11
+ num_workers: 2
12
+ learning_rate: 0.00002
13
+ weight_decay: 0.001
14
+
15
+ arcface_scale: 30.0
16
+ arcface_margin: 0.5
17
+
18
+ use_amp: true
19
+ gradient_accumulation: 4
20
+ max_grad_norm: 1.0
21
+ gradient_checkpointing: true
22
+
23
+ inference_batch_size: 8
24
+ use_tta: true
25
+ use_qe: true
26
+ qe_top_k: 3
27
+ use_rerank: true
28
+ rerank_k1: 20
29
+ rerank_k2: 6
30
+ rerank_lambda: 0.2
31
+ blend_raw_ratio: 0.20
configs/exp004/001.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # EVA-02 Large - 20エポック (チェックポイント再開)
5
+ # exp=000 (10ep, Best Loss 0.1355 @ep10) から再開して 20ep まで学習
6
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
7
+ image_size: 448
8
+ num_classes: 31
9
+
10
+ epochs: 20
11
+ batch_size: 4
12
+ num_workers: 2
13
+ learning_rate: 0.00002
14
+ weight_decay: 0.001
15
+
16
+ arcface_scale: 30.0
17
+ arcface_margin: 0.5
18
+
19
+ use_amp: true
20
+ gradient_accumulation: 4
21
+ max_grad_norm: 1.0
22
+ gradient_checkpointing: true
23
+
24
+ # チェックポイント再開設定
25
+ resume_from: "/home/naoto/workspace/Kaggle/Jaguar_Re_Identification/output/experiments/exp004_0938_optimal_blending/000/best_model.pth"
26
+ start_epoch: 10 # epoch 10 (0-indexed) = epoch 11 から再開
27
+
28
+ inference_batch_size: 8
29
+ use_tta: true
30
+ use_qe: true
31
+ qe_top_k: 3
32
+ use_rerank: true
33
+ rerank_k1: 20
34
+ rerank_k2: 6
35
+ rerank_lambda: 0.2
36
+ blend_raw_ratio: 0.20
configs/exp004/config.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - _self_
3
+ # defaultはpythonスクリプト中で登録する
4
+ - exp: default
5
+ - env: default
6
+ # hydraで自動的にログファイルが生成されるのを防ぐ
7
+ - override hydra/job_logging: none
8
+
9
+ hydra:
10
+ output_subdir: null
11
+ job:
12
+ chdir: False
13
+ run:
14
+ dir: .
configs/exp005/000.yaml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # ベースモデル (exp004 と同一)
5
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
6
+ image_size: 448
7
+ num_classes: 31
8
+
9
+ # Phase 1: ベースモデル (exp004 の checkpoint をロード)
10
+ base_model_path: "output/experiments/exp004_0938_optimal_blending/000/best_model.pth"
11
+ epochs: 10 # ベースモデル学習 (base_model_path がある場合はスキップ)
12
+
13
+ # Pseudo-Labeling 設定
14
+ pseudo_threshold: 0.90
15
+ pseudo_max_per_class: 500
16
+
17
+ # Phase 2: Fine-tuning 設定
18
+ finetune_epochs: 5
19
+ finetune_learning_rate: 0.00001
20
+
21
+ # Augmentation
22
+ use_strong_augmentation: true
23
+
24
+ # 共通設定 (exp004 と同一)
25
+ batch_size: 4
26
+ num_workers: 2
27
+ learning_rate: 0.00002
28
+ weight_decay: 0.001
29
+ arcface_scale: 30.0
30
+ arcface_margin: 0.5
31
+ use_amp: true
32
+ gradient_accumulation: 4
33
+ max_grad_norm: 1.0
34
+ gradient_checkpointing: true
35
+ inference_batch_size: 8
36
+ use_tta: true
37
+ use_qe: true
38
+ qe_top_k: 3
39
+ use_rerank: true
40
+ rerank_k1: 20
41
+ rerank_k2: 6
42
+ rerank_lambda: 0.2
43
+ blend_raw_ratio: 0.20
configs/exp005/config.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - _self_
3
+ # defaultはpythonスクリプト中で登録する
4
+ - exp: default
5
+ - env: default
6
+ # hydraで自動的にログファイルが生成されるのを防ぐ
7
+ - override hydra/job_logging: none
8
+
9
+ hydra:
10
+ output_subdir: null
11
+ job:
12
+ chdir: False
13
+ run:
14
+ dir: .
configs/exp006/000.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # DINOv2 ViT-Large (register tokens 付き)
5
+ backbone: "vit_large_patch14_reg4_dinov2.lvd142m"
6
+ image_size: 518
7
+ num_classes: 31
8
+
9
+ epochs: 10
10
+ batch_size: 4
11
+ num_workers: 2
12
+ learning_rate: 0.00002
13
+ weight_decay: 0.001
14
+
15
+ arcface_scale: 30.0
16
+ arcface_margin: 0.5
17
+
18
+ use_amp: true
19
+ gradient_accumulation: 4
20
+ max_grad_norm: 1.0
21
+ gradient_checkpointing: true
22
+
23
+ inference_batch_size: 8
24
+ use_tta: true
25
+ use_qe: true
26
+ qe_top_k: 3
27
+ use_rerank: true
28
+ rerank_k1: 20
29
+ rerank_k2: 6
30
+ rerank_lambda: 0.2
31
+ blend_raw_ratio: 0.20
configs/exp006/001.yaml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # DINOv2 ViT-Large - 20エポック (チェックポイント再開)
5
+ # exp=000 (10ep, Best Loss 0.3982 @ep9) から再開して 20ep まで学習
6
+ backbone: "vit_large_patch14_reg4_dinov2.lvd142m"
7
+ image_size: 518
8
+ num_classes: 31
9
+
10
+ epochs: 20
11
+ batch_size: 4
12
+ num_workers: 2
13
+ learning_rate: 0.00002
14
+ weight_decay: 0.001
15
+
16
+ arcface_scale: 30.0
17
+ arcface_margin: 0.5
18
+
19
+ use_amp: true
20
+ gradient_accumulation: 4
21
+ max_grad_norm: 1.0
22
+ gradient_checkpointing: true
23
+
24
+ # チェックポイント再開設定
25
+ resume_from: "/home/naoto/workspace/Kaggle/Jaguar_Re_Identification/output/experiments/exp006_dinov2/000/best_model.pth"
26
+ start_epoch: 10 # epoch 10 (0-indexed) = epoch 11 から再開
27
+
28
+ inference_batch_size: 8
29
+ use_tta: true
30
+ use_qe: true
31
+ qe_top_k: 3
32
+ use_rerank: true
33
+ rerank_k1: 20
34
+ rerank_k2: 6
35
+ rerank_lambda: 0.2
36
+ blend_raw_ratio: 0.20
configs/exp006/config.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - _self_
3
+ # defaultはpythonスクリプト中で登録する
4
+ - exp: default
5
+ - env: default
6
+ # hydraで自動的にログファイルが生成されるのを防ぐ
7
+ - override hydra/job_logging: none
8
+
9
+ hydra:
10
+ output_subdir: null
11
+ job:
12
+ chdir: False
13
+ run:
14
+ dir: .
configs/exp007/000.yaml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # exp007: 学習戦略改善 (Layer-wise LR + Warmup + EMA)
5
+ # ベース: exp004/000 (EVA-02 Large, 10ep, LB 0.946)
6
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
7
+ image_size: 448
8
+ num_classes: 31
9
+
10
+ epochs: 10
11
+ batch_size: 4
12
+ num_workers: 2
13
+ learning_rate: 0.00002
14
+ weight_decay: 0.001
15
+
16
+ arcface_scale: 30.0
17
+ arcface_margin: 0.5
18
+
19
+ use_amp: true
20
+ gradient_accumulation: 4
21
+ max_grad_norm: 1.0
22
+ gradient_checkpointing: true
23
+
24
+ # 新機能: Layer-wise LR Decay
25
+ use_layerwise_lr: true
26
+ lr_decay_rate: 0.75
27
+
28
+ # 新機能: Linear Warmup + Cosine Decay
29
+ use_warmup: true
30
+ warmup_epochs: 1.0
31
+
32
+ # 新機能: EMA
33
+ use_ema: true
34
+ ema_decay: 0.999
35
+
36
+ # 推論 (exp004 と同一)
37
+ inference_batch_size: 8
38
+ use_tta: true
39
+ use_qe: true
40
+ qe_top_k: 3
41
+ use_rerank: true
42
+ rerank_k1: 20
43
+ rerank_k2: 6
44
+ rerank_lambda: 0.2
45
+ blend_raw_ratio: 0.20
configs/exp007/001.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # exp007/001: lr_decay_rate=0.95 (穏やかな Layer-wise LR) + Warmup + EMA
5
+ # exp=000 の lr_decay_rate=0.75 が aggressive すぎて大幅劣化 → 0.95 に緩和
6
+ # 0.95^26 ≈ 0.264 → 最浅層 LR = 2e-5 * 0.264 ≈ 5.3e-6 (十分な学習が可能)
7
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
8
+ image_size: 448
9
+ num_classes: 31
10
+
11
+ epochs: 10
12
+ batch_size: 4
13
+ num_workers: 2
14
+ learning_rate: 0.00002
15
+ weight_decay: 0.001
16
+
17
+ arcface_scale: 30.0
18
+ arcface_margin: 0.5
19
+
20
+ use_amp: true
21
+ gradient_accumulation: 4
22
+ max_grad_norm: 1.0
23
+ gradient_checkpointing: true
24
+
25
+ # Layer-wise LR Decay (穏やかに)
26
+ use_layerwise_lr: true
27
+ lr_decay_rate: 0.95
28
+
29
+ # Linear Warmup + Cosine Decay
30
+ use_warmup: true
31
+ warmup_epochs: 1.0
32
+
33
+ # EMA
34
+ use_ema: true
35
+ ema_decay: 0.999
36
+
37
+ # 推論 (exp004 と同一)
38
+ inference_batch_size: 8
39
+ use_tta: true
40
+ use_qe: true
41
+ qe_top_k: 3
42
+ use_rerank: true
43
+ rerank_k1: 20
44
+ rerank_k2: 6
45
+ rerank_lambda: 0.2
46
+ blend_raw_ratio: 0.20
configs/exp007/002.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - default@_here_ # defaultの値を設定してから上書きする
3
+
4
+ # exp007/002: Layer-wise LR OFF + Warmup + EMA (ablation)
5
+ # exp004 と同じ全層同一LR に、Warmup + EMA のみ追加
6
+ # Layer-wise LR の効果を分離して検証
7
+ backbone: "eva02_large_patch14_448.mim_m38m_ft_in22k_in1k"
8
+ image_size: 448
9
+ num_classes: 31
10
+
11
+ epochs: 10
12
+ batch_size: 4
13
+ num_workers: 2
14
+ learning_rate: 0.00002
15
+ weight_decay: 0.001
16
+
17
+ arcface_scale: 30.0
18
+ arcface_margin: 0.5
19
+
20
+ use_amp: true
21
+ gradient_accumulation: 4
22
+ max_grad_norm: 1.0
23
+ gradient_checkpointing: true
24
+
25
+ # Layer-wise LR Decay: OFF (全層同一LR = exp004と同等)
26
+ use_layerwise_lr: false
27
+ lr_decay_rate: 0.95
28
+
29
+ # Linear Warmup + Cosine Decay
30
+ use_warmup: true
31
+ warmup_epochs: 1.0
32
+
33
+ # EMA
34
+ use_ema: true
35
+ ema_decay: 0.999
36
+
37
+ # 推論 (exp004 と同一)
38
+ inference_batch_size: 8
39
+ use_tta: true
40
+ use_qe: true
41
+ qe_top_k: 3
42
+ use_rerank: true
43
+ rerank_k1: 20
44
+ rerank_k2: 6
45
+ rerank_lambda: 0.2
46
+ blend_raw_ratio: 0.20
configs/exp007/config.yaml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ defaults:
2
+ - _self_
3
+ # defaultはpythonスクリプト中で登録する
4
+ - exp: default
5
+ - env: default
6
+ # hydraで自動的にログファイルが生成されるのを防ぐ
7
+ - override hydra/job_logging: none
8
+
9
+ hydra:
10
+ output_subdir: null
11
+ job:
12
+ chdir: False
13
+ run:
14
+ dir: .
docs/KAGGLE_DIRECTION.md ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # KAGGLE_DIRECTION: コンペティション ワークフロー
2
+
3
+ ## 対象コンペ情報
4
+
5
+ - **コンペ名**: Jaguar Re-Identification
6
+ - **URL**: (ここに記入)
7
+ - **期間**: (ここに記入)
8
+ - **評価指標**: (ここに記入)
9
+
10
+ ## ディレクトリ構造ガイド
11
+
12
+ ```text
13
+ Jaguar_Re_Identification/
14
+ ├── competition/ # コンペ情報(EDA結果、類似コンペ調査)
15
+ │ ├── overview.md # コンペ概要・EDAまとめ
16
+ │ └── related_competitions.md # 類似コンペの知見
17
+
18
+ ├── survey/ # 調査蓄積
19
+ │ ├── papers/ # 論文調査
20
+ │ └── discussion/ # ディスカッション定点観測
21
+
22
+ ├── experiments/ # 実験コード
23
+ │ ├── exp{NNN}_{名前}/ # 人間用実験
24
+ │ └── exp{A-Z}{NN}_{名前}/ # Claude用実験
25
+
26
+ ├── docs/
27
+ │ └── experiments.md # 実験記録 & 知見集約
28
+
29
+ ├── input/ # 入力データ
30
+ ├── output/ # 実験出力
31
+ ├── notebooks/ # Jupyter notebooks
32
+ ├── tools/ # ユーティリティツール
33
+ └── utils/ # 共通ユーティリティ
34
+ ```
35
+
36
+ ## 実験フォルダ命名規則
37
+
38
+ ### 人間用実験
39
+ `experiments/exp{NNN}_{実験名}/`
40
+ - `NNN`: 3桁の数字(000, 001, 002, ...)
41
+ - 例: `exp001_baseline`, `exp002_feature_engineering`
42
+
43
+ ### Claude用実験
44
+ `experiments/exp{A-Z}{NN}_{実験名}/`
45
+ - `{A-Z}`: アルファベット1文字。方針変更時にインクリメント(A→B→C...)
46
+ - `{NN}`: 2桁の数字。同一方針内の実験番号(00, 01, 02, ...)
47
+ - 例: `expA00_baseline`, `expA01_add_features`, `expB00_new_approach`
48
+
49
+ ### minor バージョン(exp/ 配下の yaml)
50
+ - 各実験フォルダ内の `exp/` ディレクトリに配置
51
+ - `exp/{NNN}.yaml` で管理(000, 001, 002, ...)
52
+
53
+ ## セッション記録ルール
54
+
55
+ 各実験フォルダには `SESSION_NOTES.md` を必ず配置する。
56
+
57
+ ### SESSION_NOTES.md の構造
58
+
59
+ ```markdown
60
+ # SESSION_NOTES: {実験名}
61
+
62
+ ## セッション N
63
+ - **日付**: YYYY-MM-DD
64
+ - **目標**: (このセッションで達成したいこと)
65
+
66
+ ### 仮説
67
+ ### 試したアプローチと結果(定量値含む)
68
+ ### ファイル構成
69
+ ### 重要な知見
70
+ ### 次のステップ
71
+ ### 性能変化の記録
72
+ ### コマンド履歴
73
+ ```
74
+
75
+ ### 運用ルール
76
+ - セッション開始時に新しいセッションセクションを追加
77
+ - 実験結果は定量値(CV, LB スコア)を必ず記録
78
+ - セッション終了時に「次のステップ」を記入し、次回セッションの引き継ぎに使う
79
+
80
+ ## コンペ進行方法
81
+
82
+ ### 1. EDA フェーズ
83
+ 1. データを `input/` に配置
84
+ 2. `notebooks/` で EDA を実施
85
+ 3. 結果を `competition/overview.md` にまとめる
86
+
87
+ ### 2. 調査フェーズ
88
+ 1. 類似コンペの上位解法を調査 → `competition/related_competitions.md`
89
+ 2. 関連論文を調査 → `survey/papers/`
90
+ 3. Kaggle Discussion を定期的に確認 → `survey/discussion/`
91
+
92
+ ### 3. ベースライン構築
93
+ 1. 最初の実験フォルダを作成(例: `exp001_baseline` or `expA00_baseline`)
94
+ 2. シンプルなモデルで End-to-End パイプラインを構築
95
+ 3. CV と LB の相関を確認
96
+
97
+ ### 4. 改善サイクル
98
+ 1. 仮説を立てる → SESSION_NOTES.md に記録
99
+ 2. 実験を実施 → 結果を記録
100
+ 3. 知見を `docs/experiments.md` に集約
101
+ 4. 次の仮説を立てる
102
+
103
+ ## 学習コードの要件
104
+
105
+ - **学習ログ**: wandb で損失値、評価指標、学習率を記録
106
+ - **途中再開**: チェックポイントからの再開をサポート(長時間学習の場合)
107
+ - **AMP (Automatic Mixed Precision)**: GPU メモリ効率化のため推奨
108
+ - **シード固定**: 再現性のため `seed` を設定で管理
109
+
110
+ ## survey/ の運用ガイド
111
+
112
+ ### 論文調査 (`survey/papers/`)
113
+ - 詳細は `survey/papers/README.md` を参照
114
+ - ファイル命名: `{YYYY}_{著者名}_{短縮タイトル}.md`
115
+
116
+ ### ディスカッション定点観測 (`survey/discussion/`)
117
+ - 詳細は `survey/discussion/README.md` を参照
118
+ - JSON スクレイピングデータは gitignore 対象
119
+
120
+ ## competition/ の運用ガイド
121
+
122
+ - `competition/overview.md`: EDA 結果のまとめ。コンペ開始時に記入。
123
+ - `competition/related_competitions.md`: 類似コンペの調査結果。ベースライン構築前に記入。
docs/TODO.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # TODO
2
+
3
+ ## 現在実行中
4
+
5
+ (なし)
6
+
7
+ ## 実装完了
8
+ - [x] exp001_baseline: run.py 実装 (JaguarDataset, EmbeddingModel, ArcFaceHead, train, validate, generate_submission)
9
+ - [x] exp001_baseline: config.yaml, exp/000.yaml (zero_shot), exp/001.yaml (arcface)
10
+ - [x] pyproject.toml に timm 追加
11
+ - [x] docs/experiments.md 作成
12
+ - [x] exp002_public_baseline: 公開ノートブックベースラインの実装
13
+ - [x] pyproject.toml に albumentations 追加
14
+ - [x] exp002_public_baseline: デバッグモード動作確認 (3エポック正常完了)
15
+ - [x] exp002_public_baseline: exp=000 通常モード完了 (25エポック, LB 0.781)
16
+ - [x] exp003_eva02_baseline: EVA-02 Large ベースライン実装
17
+ - [x] exp003_eva02_baseline: デバッグモード動作確認完了 (3エポック正常完了)
18
+ - [x] exp003_eva02_baseline: exp=000 通常モード完了 (10エポック, LB 0.921)
19
+ - [x] exp004_0938_optimal_blending: 0.938 NB 実装 (run.py, config, exp/000.yaml)
20
+ - [x] exp004_0938_optimal_blending: デバッグモード動作確認完了 (3エポック正常完了)
21
+ - [x] exp004_0938_optimal_blending: exp=000 通常モード完了 (10エポック, Loss 0.1355, Acc 98.47%, LB 0.946)
22
+ - [x] exp005_pseudo_labeling: 通常モード実行完了 (5ep fine-tune, Loss 0.0731, Acc 99.20%, LB 0.937)
23
+ - [x] ensemble exp004+005 weighted 0.7/0.3: LB 0.948 (現ベスト)
24
+ - [x] 4モデル並列コードレビュー (exp003/004/005 改善可能性分析)
25
+ - [x] exp006_dinov2: 実装・デバッグ・通常モード完了 (10ep, Best Loss 0.3982, Acc 95.14%, LB 提出待ち)
26
+ - [x] exp006_dinov2: exp=001 通常モード完了 (20ep, Best Loss 0.0827 @ep19, Acc 98.94%, LB 0.925)
27
+ - [x] exp006_dinov2: LB 提出完了 (exp=000: LB 0.897, exp=001: LB 0.925)
28
+ - [x] exp003_eva02_baseline: exp=001 通常モード完了 (20ep, Best Loss 0.3035, Acc 96.78%, **LB 0.913** ← 10ep 0.921より悪化)
29
+ - [x] exp004_0938_optimal_blending: exp=001 通常モード完了 (20ep, Best Loss 0.0481 @ep19, Acc 99.42%, **LB 0.945** ← 10ep 0.946とほぼ同等)
30
+ - [x] exp007_improved_training: 実装・デバッグ・通常モード完了 (10ep, Best Loss 4.4556, Acc 48.94%, LB 提出済み) ← **大幅劣化**: lr_decay_rate=0.75が aggressive すぎてbackbone学習不足
31
+
32
+ ## 実装中
33
+ (なし)
34
+
35
+ ## 実装予定
36
+
37
+ ### 優先度1: exp003/exp004 20ep 延長学習
38
+ - [x] exp003_eva02_baseline: チェックポイント再開実装
39
+ - [x] exp003_eva02_baseline: exp=001 通常モード (20ep) → LB 提出済み
40
+ - [x] exp004_0938_optimal_blending: チェックポイント再開実装
41
+ - [x] exp004_0938_optimal_blending: exp=001 通常モード (20ep) → LB 提出済み
42
+ - [x] exp004/exp006 アンサンブル検証完了 (2-model best: w80/20 LB 0.947, 3-model best: w50/30/20 LB 0.948 → 現ベスト0.948と同等、超えられず)
43
+
44
+ ### 優先度2: exp007 改良版 - 学習戦略改善 (Layer-wise LR + Warmup + EMA)
45
+ - [x] exp007: Layer-wise LR Decay (backbone浅い層: 小LR, head: 大LR)
46
+ - [x] exp007: Linear Warmup + Cosine Decay scheduler (per-step)
47
+ - [x] exp007: EMA (Exponential Moving Average, decay=0.999, timm ModelEmaV2)
48
+ - [x] exp007: デバッグモード動作確認完了 (3ep正常完了)
49
+ - [x] exp007: 通常モード実行完了・LB 提出済み (10ep, Loss 4.4556, Acc 48.94%, **大幅劣化**)
50
+ - [x] exp007: exp=001 lr_decay_rate=0.95 + Warmup + EMA → Loss 0.3466, Acc 95.56% (exp004以下)
51
+ - [x] exp007: exp=002 Layer-wise LR OFF + Warmup + EMA → Loss 0.1904, Acc 97.83% (exp004以下)
52
+ - **結論**: Layer-wise LR / Warmup / EMA いずれも exp004 ベースラインを超えられず
53
+
54
+ ### 優先度3: Pseudo-Labeling 改善
55
+ - [ ] PL改善: Soft label 化 (KL-divergence loss, 温度T=2~4)
56
+ - [ ] PL改善: Pseudo loss weight (0.2~0.5 で重み付け)
57
+ - [ ] PL改善: 品質フィルタ強化 (top1-top2 margin / mutual NN 条件)
58
+ - [ ] PL改善: Iterative PL (高閾値→緩和を段階的に)
59
+ - [ ] PL改善: Backbone freeze での fine-tune
60
+
61
+ ### 優先度4: 後処理改善
62
+ - [ ] Database Augmentation (DBA): 訓練画像1,895枚のembeddingもgalleryに追加しQE/rerank
63
+ - [ ] Re-ranking パラメータ探索: k1=[15,20,25], lambda=[0.15,0.2,0.25,0.3], blend=[0.1,0.15,0.2,0.3]
64
+ - [ ] k-reciprocal 完全版実装: exp004のJaccard実装のk2パラメータ(V行列平滑化)を有効化
65
+ - [ ] alpha-QE (重み付きQuery Expansion): weight_i = sim_i^alpha (alpha=2~3)
66
+ - [ ] Embedding レベルアンサンブル: score average ではなく embedding concat/average → rerank
67
+
68
+ ### 優先度5: モデルアーキテクチャ改善
69
+ - [ ] Sub-center ArcFace (K=2~3): クラス内バリエーション対応
70
+ - [ ] AdaFace (quality-adaptive margin): 画像品質に応じたマージン調整
71
+ - [ ] ArcFace margin scheduling: 学習序盤 margin=0.1 → 0.5 まで漸増
72
+ - [ ] Triplet Loss + PK Sampler: ArcFace に加えて Triplet Loss を補助追加
73
+ - [ ] Multi-scale pooling: GeM(p=1) + GeM(p=3) + MaxPool を concat
74
+ - [ ] GeM + CLS token concat: CLS トークンも活用
75
+ - [ ] Dropout before ArcFace: BN と ArcFace 間に Dropout(0.1~0.3)
76
+
77
+ ### 優先度6: データ拡張改善
78
+ - [ ] RandomResizedCrop(448, scale=(0.75, 1.0)): 部分模様の識別力向上
79
+ - [ ] RandomPerspective(distortion_scale=0.2, p=0.3): 視点変化ロバスト性
80
+ - [ ] GridMask / CoarseDropout: 構造的遮蔽パターン
81
+ - [ ] Augmentation 強度調整: degrees=20~30, ColorJitter強度増加
82
+
83
+ ### 優先度7: その他改善
84
+ - [ ] K-Fold CV (Stratified 5-fold): fold ensemble + 信頼性のある評価
85
+ - [ ] Multi-seed アンサンブル: seed=42, 123, 777 で3回学習 → embedding 平均
86
+ - [ ] Multi-scale 推論: 384/448/512 の3スケールで embedding 抽出し平均
87
+ - [ ] 入力解像度向上: 448 → 560px (position embedding 補間)
88
+ - [ ] Backbone Freezing + Gradual Unfreezing: 最初数エポックは backbone フリーズ
89
+ - [ ] Part-based Re-ID: 画像を水平2~3分割し部分特徴量抽出
90
+ - [ ] 外部データ活用: iNaturalist Jaguar, LeopardID 等 (ルール確認要)
91
+
92
+ ### 保留
93
+ - [ ] exp001_baseline: GPU 空き次第 exp=000 (zero-shot) を実行して動作確認
94
+ - [ ] exp001_baseline: exp=001 (ArcFace fine-tune) を実行
docs/experiments.md ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 実験記録 & 知見集約
2
+
3
+ ## 実験一覧
4
+
5
+ | 実験フォルダ | 所有者 | 概要 | CV | LB | 主な知見 |
6
+ |------------|--------|------|----|----|---------|
7
+ | exp000_sample | 人間 | サンプル実験。テンプレートの動作確認用。 | - | - | - |
8
+ | exp001_baseline | 人間 | MegaDescriptor ベースライン | - | - | GPU メモリ制約に注意 |
9
+ | exp002_public_baseline | 人間 | 公開ノートブックベースライン (MegaDescriptor-B-224 + Sub-center ArcFace) | - | 0.781 | - |
10
+ | exp003_eva02_baseline | Claude | EVA-02 Large ベースライン (EVA-02-L-448 + GeM + Standard ArcFace) | - | 0.921 | 大規模 backbone が効果大 |
11
+ | exp004_0938_optimal_blending | Claude | 0.938 NB 実装 (FC層削除 + Jaccard rerank + Optimal Blending) | - | 0.946 | exp003 ベース、公開NB差分適用、元NB 0.938 を超過 |
12
+ | exp005_pseudo_labeling | Claude | Pseudo-Labeling (exp004ベース + テスト画像擬似ラベル fine-tuning) | - | 0.937 | exp004比 -0.009 悪化、embedding識別力低下 |
13
+ | exp006_dinov2 | Claude | DINOv2 ViT-L backbone (異種モデルアンサンブル用) | - | 提出待ち | 000: 10ep Best Loss 0.3982 @ep9, 001: 20ep Best Loss 0.0827 @ep19, Acc 98.94% |
14
+ | exp007_improved_training | Claude | 学習戦略改善 (Layer-wise LR + Warmup + EMA) | - | 提出済み | **結論**: 3改善いずれも exp004 ベースライン超えられず (best: 002 Loss 0.1904, Acc 97.83%) |
15
+
16
+ ### exp000_sample
17
+
18
+ テンプレート確認用のサンプル実験。実質的な処理は行わない。
19
+
20
+ | minor version | 説明 | CV | LB |
21
+ |---|---|---|---|
22
+ | 000 | seed=0, folds=[0] | - | - |
23
+ | 001 | seed=634 | - | - |
24
+
25
+ ### exp001_baseline
26
+
27
+ MegaDescriptor を使ったジャガー再識別ベースライン。
28
+
29
+ | minor version | mode | 説明 | 主要パラメータ | CV | LB |
30
+ |---|---|---|---|---|---|
31
+ | 000 | zero_shot | 事前学習済みモデルのみ (学習なし) | model=MegaDescriptor-L-384, image_size=384 | - | - |
32
+ | 001 | arcface | ArcFace fine-tune (31クラス分類) | epochs=10, batch_size=16, lr=1e-4, scale=30, margin=0.5 | - | - |
33
+
34
+ #### 実行コマンド
35
+
36
+ ```bash
37
+ # Zero-shot
38
+ uv run python -m experiments.exp001_baseline.run exp=000
39
+
40
+ # ArcFace fine-tune
41
+ uv run python -m experiments.exp001_baseline.run exp=001
42
+
43
+ # デバッグモード (wandb無効)
44
+ uv run python -m experiments.exp001_baseline.run exp=000 exp.debug=true
45
+ ```
46
+
47
+ #### 設定ファイルの場所
48
+
49
+ - 共通設定: `experiments/exp001_baseline/config.yaml`
50
+ - 実験別設定: `experiments/exp001_baseline/exp/000.yaml`, `001.yaml`
51
+ - デフォルト値: `experiments/exp001_baseline/run.py` 内の `ExpConfig` dataclass
52
+
53
+ ### exp002_public_baseline
54
+
55
+ 公開ノートブック ([ibrahimqasimi/jaguar-re-identification-challenge-baseline](https://www.kaggle.com/code/ibrahimqasimi/jaguar-re-identification-challenge-baseline)) をベースにした実験。
56
+
57
+ exp001 との主な違い:
58
+ - Backbone: MegaDescriptor-B-224 (exp001: L-384)
59
+ - ArcFace: Sub-center (k=2) (exp001: Standard)
60
+ - Loss: Focal Loss (gamma=2.0) (exp001: CrossEntropy)
61
+ - Augmentation: albumentations (多数) (exp001: 基本的)
62
+ - Neck: 2層 MLP + BN + PReLU (exp001: なし)
63
+ - Class Balancing: WeightedRandomSampler (exp001: なし)
64
+ - AMP + Gradient Accumulation (exp001: なし)
65
+ - 推論: TTA, k-reciprocal re-ranking, calibration, ensemble (exp001: cosine類似度のみ)
66
+
67
+ | minor version | 説明 | 主要パラメータ | CV | LB |
68
+ |---|---|---|---|---|
69
+ | 000 | 公開ノートブックデフォルト設定 | backbone=B-224, epochs=25, bs=8, accum=4, lr=2e-4, subcenter_k=2 | - | - |
70
+
71
+ #### 実行コマンド
72
+
73
+ ```bash
74
+ # 通常実行
75
+ uv run python -m experiments.exp002_public_baseline.run exp=000
76
+
77
+ # デバッグモード (wandb無効)
78
+ uv run python -m experiments.exp002_public_baseline.run exp=000 exp.debug=true
79
+ ```
80
+
81
+ #### 設定ファイルの場所
82
+
83
+ - 共通設定: `experiments/exp002_public_baseline/config.yaml`
84
+ - 実験別設定: `experiments/exp002_public_baseline/exp/000.yaml`
85
+ - デフォルト値: `experiments/exp002_public_baseline/run.py` 内の `ExpConfig` dataclass
86
+
87
+ #### 出力ファイル
88
+
89
+ 5種類の submission を生成:
90
+ 1. `submission_baseline.csv`: Cosine similarity (ベースライン)
91
+ 2. `submission_tta.csv`: Test-Time Augmentation
92
+ 3. `submission_rerank.csv`: k-Reciprocal re-ranking
93
+ 4. `submission_calibrated.csv`: Percentile calibration
94
+ 5. `submission_ensemble.csv`: 加重アンサンブル (0.4*TTA + 0.35*rerank + 0.25*calibrated)
95
+ 6. `submission.csv`: ensemble のコピー (メイン提出用)
96
+
97
+ ### exp003_eva02_baseline
98
+
99
+ 公開ノートブック ([lakhindarpal/jaguar-re-identification-challenge](https://www.kaggle.com/code/lakhindarpal/jaguar-re-identification-challenge)) をベースにした実験。
100
+
101
+ exp002 との主な違い:
102
+ - Backbone: EVA-02 Large 448px (~300M params) (exp002: MegaDescriptor-B-224, 88M)
103
+ - Image size: 448 (exp002: 224)
104
+ - Pooling: GeM (Generalized Mean Pooling) (exp002: Global Average)
105
+ - ArcFace: Standard (exp002: Sub-center k=2)
106
+ - Loss: CrossEntropy (exp002: Focal Loss gamma=2.0)
107
+ - Augmentation: torchvision (基本的) (exp002: albumentations 多数)
108
+ - Neck: BN のみ (exp002: 2層 MLP + BN + PReLU)
109
+ - Class Balancing: なし (exp002: WeightedRandomSampler)
110
+ - Post-processing: TTA + Query Expansion + re-ranking (exp002: TTA + rerank + calibration + ensemble)
111
+ - Epochs: 10 (exp002: 25)
112
+ - LR: 2e-5 (exp002: 2e-4)
113
+ - Effective batch: 16 (exp002: 32)
114
+ - Scheduler: CosineAnnealingLR warmup なし (exp002: Cosine + linear warmup)
115
+
116
+ | minor version | 説明 | 主要パラメータ | CV | LB |
117
+ |---|---|---|---|---|
118
+ | 000 | 公開ノートブックデフォルト設定 | backbone=EVA-02-L-448, epochs=10, bs=4, accum=4, lr=2e-5 | - | 0.921 |
119
+
120
+ #### 実行コマンド
121
+
122
+ ```bash
123
+ # 通常実行
124
+ uv run python -m experiments.exp003_eva02_baseline.run exp=000
125
+
126
+ # デバッグモード (wandb無効)
127
+ uv run python -m experiments.exp003_eva02_baseline.run exp=000 exp.debug=true
128
+ ```
129
+
130
+ #### 設定ファイルの場所
131
+
132
+ - 共通設定: `experiments/exp003_eva02_baseline/config.yaml`
133
+ - 実験別設定: `experiments/exp003_eva02_baseline/exp/000.yaml`
134
+ - デフォルト値: `experiments/exp003_eva02_baseline/run.py` 内の `ExpConfig` dataclass
135
+
136
+ #### 出力ファイル
137
+
138
+ 5種類の submission を生成:
139
+ 1. `submission_baseline.csv`: Cosine similarity (ベースライン)
140
+ 2. `submission_tta.csv`: Test-Time Augmentation (horizontal flip)
141
+ 3. `submission_qe.csv`: Query Expansion (top_k=3)
142
+ 4. `submission_rerank.csv`: k-Reciprocal re-ranking
143
+ 5. `submission_ensemble.csv`: 加重アンサンブル (0.4*TTA + 0.3*QE + 0.3*rerank)
144
+ 6. `submission.csv`: ensemble のコピー (メイン提出用)
145
+
146
+ ### exp004_0938_optimal_blending
147
+
148
+ 公開ノートブック ([sanidhyavijay24/jaguar-re-id-0-938-eva-02-optimal-blending](https://www.kaggle.com/code/sanidhyavijay24/jaguar-re-id-0-938-eva-02-optimal-blending)) をベースにした実験。
149
+
150
+ exp003 との主な違い:
151
+ - Neck: FC 層削除 (backbone_dim → BN → ArcFace 直接) (exp003: BN → FC(1024) → BN2)
152
+ - Normalize: [0.481, 0.457, 0.408] / [0.268, 0.261, 0.275] (exp003: ImageNet)
153
+ - CLS トークン: if H*W != N: features[:, -(H*W):, :] (exp003: num_prefix_tokens)
154
+ - TTA: バッチ内 flip (exp003: 別パス平均)
155
+ - Re-ranking: Jaccard 距離ベース k-reciprocal (exp003: expansion-based)
156
+ - rerank_lambda: 0.2 (exp003: 0.3)
157
+ - Blending: 0.2*raw + 0.8*reranked Optimal (exp003: 0.4*TTA + 0.3*QE + 0.3*rerank)
158
+ - ArcFace input: backbone_dim そのまま (exp003: embedding_dim=1024)
159
+
160
+ | minor version | 説明 | 主要パラメータ | CV | LB |
161
+ |---|---|---|---|---|
162
+ | 000 | 0.938 NB デフォルト設定 | backbone=EVA-02-L-448, epochs=10, bs=4, accum=4, lr=2e-5, lambda=0.2, blend=0.2/0.8 | - | 0.946 |
163
+
164
+ #### 実行コマンド
165
+
166
+ ```bash
167
+ # 通常実行
168
+ uv run python -m experiments.exp004_0938_optimal_blending.run exp=000
169
+
170
+ # デバッグモード (wandb無効)
171
+ uv run python -m experiments.exp004_0938_optimal_blending.run exp=000 exp.debug=true
172
+ ```
173
+
174
+ #### 設定ファイルの場所
175
+
176
+ - 共通設定: `experiments/exp004_0938_optimal_blending/config.yaml`
177
+ - 実験別設定: `experiments/exp004_0938_optimal_blending/exp/000.yaml`
178
+ - デフォルト値: `experiments/exp004_0938_optimal_blending/run.py` 内の `ExpConfig` dataclass
179
+
180
+ #### 出力ファイル
181
+
182
+ 5種類の submission を生成:
183
+ 1. `submission_baseline.csv`: Raw cosine similarity (TTA なし)
184
+ 2. `submission_tta.csv`: In-batch flip TTA
185
+ 3. `submission_rerank.csv`: QE → Jaccard k-reciprocal re-ranking (lambda=0.2)
186
+ 4. `submission_optimal_blend.csv`: 20% raw + 80% reranked (Optimal Blending)
187
+ 5. `submission.csv`: optimal_blend のコピー (メイン提出用)
188
+
189
+ ### exp005_pseudo_labeling
190
+
191
+ 公開ノートブック ([kawaharataishi/pseudo-labeling](https://www.kaggle.com/code/kawaharataishi/pseudo-labeling/notebook)) をベースにした Pseudo-Labeling (Self-Training) 実験。
192
+
193
+ exp004 との主な違い:
194
+ - 学習フロー: exp004 best_model.pth ロード → テスト画像擬似ラベル生成 → 結合データで fine-tuning
195
+ - 訓練データ: train.csv + pseudo_labels (テスト画像の高確信度予測)
196
+ - Augmentation: + SharpenTransform(p=0.3) + RandomErasing(p=0.25)
197
+ - LR: 1e-5 (fine-tuning 用に低め)
198
+ - エポック: 5 (fine-tuning 用に少なめ)
199
+ - 推論・後処理: exp004 と同一 (Optimal Blend)
200
+
201
+ | minor version | 説明 | 主要パラメータ | CV | LB |
202
+ |---|---|---|---|---|
203
+ | 000 | デフォルト設定 | threshold=0.90, max_per_class=500, finetune_epochs=5, lr=1e-5 | - | 0.937 |
204
+
205
+ #### 実行コマンド
206
+
207
+ ```bash
208
+ # 通常実行
209
+ uv run python -m experiments.exp005_pseudo_labeling.run exp=000
210
+
211
+ # デバッグモード (wandb無効)
212
+ uv run python -m experiments.exp005_pseudo_labeling.run exp=000 exp.debug=true
213
+ ```
214
+
215
+ #### 設定ファイルの場所
216
+
217
+ - 共通設定: `experiments/exp005_pseudo_labeling/config.yaml`
218
+ - 実験別設定: `experiments/exp005_pseudo_labeling/exp/000.yaml`
219
+ - デフォルト値: `experiments/exp005_pseudo_labeling/run.py` 内の `ExpConfig` dataclass
220
+
221
+ #### 出力ファイル
222
+
223
+ - `pseudo_labels.csv`: 生成された擬似ラベル一覧 (filename, ground_truth, label, confidence)
224
+ - `best_model_finetuned.pth`: fine-tuning 後のベストモデル
225
+ - 5種類の submission (exp004 と同一): baseline, TTA, rerank, optimal_blend, main
226
+
227
+ ### exp006_dinov2
228
+
229
+ DINOv2 ViT-Large backbone による異種モデル実験。アンサンブルの多様性向上が目的。
230
+
231
+ exp004 との主な違い:
232
+ - Backbone: EVA-02-L-448 → DINOv2 ViT-L reg4 (自己教師あり学習 vs MIM)
233
+ - Image size: 448 → 518 (patch_size=14, 37x37 patches)
234
+ - Normalize: カスタム → ImageNet 標準 [0.485,0.456,0.406]/[0.229,0.224,0.225]
235
+ - CLS除去: features[:, -(H*W):, :] → features[:, num_prefix:, :] (num_prefix=5: CLS+4reg)
236
+ - dynamic_img_size=True (timm)
237
+ - その他 (GeM, ArcFace, QE, Rerank, Optimizer) は exp004 と同一
238
+
239
+ | minor version | 説明 | 主要パラメータ | CV | LB |
240
+ |---|---|---|---|---|
241
+ | 000 | DINOv2 デフォルト設定 (10ep) | backbone=DINOv2-L-reg4, epochs=10, bs=4, accum=4, lr=2e-5, img=518 | - | - |
242
+ | 001 | 20ep (チェックポイント再開) | epochs=20, resume_from=000/best_model.pth, start_epoch=10 | - | - |
243
+
244
+ #### 実行コマンド
245
+
246
+ ```bash
247
+ # 通常実行 (10ep)
248
+ uv run python -m experiments.exp006_dinov2.run exp=000
249
+
250
+ # 20ep チェックポイント再開
251
+ uv run python -m experiments.exp006_dinov2.run exp=001
252
+
253
+ # デバッグモード (wandb無効)
254
+ uv run python -m experiments.exp006_dinov2.run exp=000 exp.debug=true
255
+ ```
256
+
257
+ #### 設定ファイルの場所
258
+
259
+ - 共通設定: `experiments/exp006_dinov2/config.yaml`
260
+ - 実験別設定: `experiments/exp006_dinov2/exp/000.yaml`
261
+ - デフォルト値: `experiments/exp006_dinov2/run.py` 内の `ExpConfig` dataclass
262
+
263
+ #### 出力ファイル
264
+
265
+ 5種類の submission を生成 (exp004 と同一形式):
266
+ 1. `submission_baseline.csv`: Raw cosine similarity (TTA なし)
267
+ 2. `submission_tta.csv`: In-batch flip TTA
268
+ 3. `submission_rerank.csv`: QE → Jaccard k-reciprocal re-ranking (lambda=0.2)
269
+ 4. `submission_optimal_blend.csv`: 20% raw + 80% reranked (Optimal Blending)
270
+ 5. `submission.csv`: optimal_blend のコピー (メイン提出用)
271
+
272
+ ### exp007_improved_training
273
+
274
+ exp004 ベースに学習戦略を改善した実験。3つの改善: Layer-wise LR Decay, Linear Warmup + Cosine Decay, EMA。
275
+
276
+ exp004 との主な違い:
277
+ - Optimizer: 全パラメータ同一LR → Layer-wise LR Decay (backbone浅い層: 小LR, head: 大LR)
278
+ - Scheduler: CosineAnnealingLR → Linear Warmup (1ep) + Cosine Decay (per-step)
279
+ - EMA: なし → ModelEmaV2 (decay=0.999), 推論時にEMA weights使用
280
+
281
+ | minor version | 説明 | 主要パラメータ | CV | LB |
282
+ |---|---|---|---|---|
283
+ | 000 | 全3改善ON (10ep) | lr_decay_rate=0.75, warmup_epochs=1.0, ema_decay=0.999 | Loss 4.4556, Acc 48.94% | 提出済み |
284
+ | 001 | Layer-wise LR 穏やか (10ep) | lr_decay_rate=0.95, warmup_epochs=1.0, ema_decay=0.999 | Loss 0.3466, Acc 95.56% | 提出済み |
285
+ | 002 | Warmup+EMA のみ (10ep) | use_layerwise_lr=false, warmup_epochs=1.0, ema_decay=0.999 | Loss 0.1904, Acc 97.83% | 提出済み |
286
+
287
+ **結論**: 3つの改善 (Layer-wise LR, Warmup, EMA) はいずれも exp004 ベースライン (Loss 0.1355, Acc 98.47%, LB 0.946) を超えられなかった。Layer-wise LR は有害 (decay_rate=0.95 でも Acc 95.56%)。Warmup+EMA のみでも Acc 97.83% 止まり。
288
+
289
+ #### 実行コマンド
290
+
291
+ ```bash
292
+ # 通常実行
293
+ uv run python -m experiments.exp007_improved_training.run exp=000
294
+
295
+ # デバッグモード (wandb無効)
296
+ uv run python -m experiments.exp007_improved_training.run exp=000 exp.debug=true
297
+ ```
298
+
299
+ ## ベストスコア履歴
300
+
301
+ | 日付 | 実験 | Public LB | Private LB | 備考 |
302
+ |------|------|-----------|------------|------|
303
+ | 2026-02-11 | ensemble exp004+005 weighted 0.7/0.3 | **0.948** | - | exp004 (0.946) + exp005 PL (0.937) のアンサンブル |
304
+ | 2026-02-11 | exp004_0938_optimal_blending/000 (optimal_blend) | 0.946 | - | EVA-02-L-448 + FC削除 + Jaccard rerank + Optimal Blend |
305
+ | 2026-02-10 | exp003_eva02_baseline/000 (ensemble) | 0.921 | - | EVA-02-L-448 + GeM + ArcFace |
306
+ | 2026-02-10 | exp002_public_baseline/000 (ensemble) | 0.781 | - | MegaDescriptor-B-224 + SubCenter-ArcFace |
307
+
308
+ ## 重要な知見
309
+
310
+ ### データに関する知見
311
+
312
+ -
313
+
314
+ ### モデルに関する知見
315
+
316
+ - EVA-02 Large 448px (300M params) は MegaDescriptor-B-224 (88M) に対し LB +0.140 の大幅改善 (0.781→0.921)
317
+ - 大規模 backbone の強さが Re-ID タスクで非常に効果的
318
+
319
+ ### 前処理・後処理に関する知見
320
+
321
+ -
322
+
323
+ ## 有効なテクニック
324
+
325
+ <!-- コンペを通じて有効だと判明したテクニックを記録 -->
326
+
327
+ -
328
+
329
+ ## 避けるべきアプローチ
330
+
331
+ <!-- 試したが効果がなかった、または悪化したアプローチを記録 -->
332
+
333
+ - **Layer-wise LR Decay (EVA-02 Large)**: decay_rate=0.75 → Loss 4.4556, Acc 48.94% (大幅劣化)。decay_rate=0.95 に緩和しても Acc 95.56% で exp004 (98.47%) を下回る。EVA-02 Large では全層同一LR が最適。
334
+ - **Warmup + EMA (exp004ベース)**: 全層同一LR + Warmup(1ep) + EMA(0.999) でも Loss 0.1904, Acc 97.83% → exp004 (Loss 0.1355, Acc 98.47%) に及ばず。10ep では Warmup による序盤学習遅延を回収しきれない可能性。
logs/Log_2025-02-10.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 開発ログ 2025-02-10
2
+
3
+ ## kaggle-template への汎用設定フィードバック
4
+
5
+ Jaguar_Re_Identification プロジェクトで追加・改善した汎用的な設定を kaggle-template に反映した。
6
+
7
+ ### 実施内容
8
+
9
+ | ファイル | 操作 | 内容 |
10
+ |---|---|---|
11
+ | `CLAUDE.md` | 新規作成 | Claude Code 開発ガイドライン(View実装の原則セクションは削除) |
12
+ | `TODO.md` | 新規作成 | 空のタスク管理テンプレート |
13
+ | `docs/.gitkeep` | 新規作成 | ドキュメントディレクトリ |
14
+ | `docs/experiments.md` | 新規作成 | 実験記録テンプレート |
15
+ | `logs/.gitkeep` | 新規作成 | ログディレクトリ |
16
+ | `tests/.gitkeep` | 新規作成 | テストディレクトリ |
17
+ | `tools/upload_model.py` | 修正 | user_name デフォルト: `kami634` → `naotonishida` |
18
+ | `experiments/exp000_sample/run.py` | 修正 | WANDB_PROJECT_NAME に TODO コメント追加 |
19
+ | `README.md` | 修正 | Structure セクション更新、プロジェクト初期設定セクション追加 |
20
+
21
+ ### 反映しなかったもの
22
+ - `timm` 依存(Jaguar固有)
23
+ - `exp001_baseline/`(コンペ固有)
24
+ - `.claude/settings.local.json`(ユーザーセッション固有)
logs/Log_2026-02-10.md ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 開発ログ 2026-02-10
2
+
3
+ ## exp001_baseline 実装
4
+
5
+ ### 実施内容
6
+ - `pyproject.toml` に `timm` を追加、`uv sync` で依存をインストール
7
+ - `experiments/exp001_baseline/` を作成
8
+ - `config.yaml`: Hydra設定 (exp000_sample と同一構造)
9
+ - `exp/000.yaml`: Zero-shot モード
10
+ - `exp/001.yaml`: ArcFace fine-tune モード (epochs=10, batch_size=16, lr=1e-4)
11
+ - `run.py`: メイン実装
12
+ - `JaguarDataset`: RGBA→RGB変換(白背景合成)、リサイズ、正規化
13
+ - `EmbeddingModel`: timm の MegaDescriptor-L-384 で embedding 抽出 + L2正規化
14
+ - `ArcFaceHead`: Angular Margin Loss 分類ヘッド
15
+ - `train()`: ArcFace学習 (AdamW + CosineAnnealing + warmup)、各epochでval AUC計算
16
+ - `validate()`: val set の全ペア cosine 類似度 → AUC-ROC
17
+ - `generate_submission()`: 371枚のembedding抽出 → 137,270ペアの類似度 → CSV出力
18
+ - `docs/experiments.md`: 実験設定一覧ドキュメントを作成
19
+
20
+ ### デバッグ実行
21
+ - `exp=000 exp.debug=true` を実行したが、GPU メモリ不足 (他プロセスが 93GB 使用中) で失敗
22
+ - コード自体にはエラーなし。GPU が空いたら再実行する
23
+
24
+ ### 次のステップ
25
+ - GPU 空き次第、zero-shot (exp=000) を実行して submission.csv を確認
26
+ - ArcFace fine-tune (exp=001) を実行
27
+
28
+ ## exp002_public_baseline 実装
29
+
30
+ 公開ノートブック ([ibrahimqasimi/jaguar-re-identification-challenge-baseline](https://www.kaggle.com/code/ibrahimqasimi/jaguar-re-identification-challenge-baseline)) をプロジェクトフレームワークに統合。
31
+
32
+ ### exp001 との主な差分
33
+
34
+ | 項目 | exp001 | exp002 (公開NB) |
35
+ |------|--------|-----------------|
36
+ | Backbone | MegaDescriptor-L-384 | MegaDescriptor-B-224 |
37
+ | Image size | 384 | 224 |
38
+ | ArcFace | Standard | Sub-center (k=2) |
39
+ | Loss | CrossEntropy | Focal Loss (gamma=2.0) |
40
+ | Augmentation | torchvision (flip, resize) | albumentations (多数) |
41
+ | Neck | なし | 2層 MLP + BN + PReLU |
42
+ | Class Balancing | なし | WeightedRandomSampler |
43
+ | AMP / Grad Accum | なし | AMP + accum=4 |
44
+ | 推論 | cosine類似度のみ | TTA, k-reciprocal re-ranking, calibration, ensemble |
45
+ | Epochs | 10 | 25 |
46
+
47
+ ### 実施内容
48
+
49
+ | ファイル | 操作 | 内容 |
50
+ |---|---|---|
51
+ | `experiments/exp002_public_baseline/run.py` | 新規作成 | メイン実装 (~600行) |
52
+ | `experiments/exp002_public_baseline/config.yaml` | 新規作成 | Hydra 設定 |
53
+ | `experiments/exp002_public_baseline/exp/000.yaml` | 新規作成 | 公開NBデフォルト設定 |
54
+ | `experiments/exp002_public_baseline/SESSION_NOTES.md` | 新規作成 | セッション記録 |
55
+ | `pyproject.toml` | 修正 | albumentations>=1.3.0 追加 |
56
+ | `docs/experiments.md` | 修正 | exp002 セクション追加 |
57
+ | `TODO.md` | 修正 | exp002 タスク追加 |
58
+
59
+ ### 主要コンポーネント
60
+
61
+ - `JaguarDataset` / `JaguarTestDataset`: albumentations + alpha mask (黒背景合成)
62
+ - `SubCenterArcFace`: Sub-center ArcFace head (k=2)
63
+ - `JaguarReIDModel`: backbone + neck (2層MLP+BN+PReLU) + head (gradient checkpointing対応)
64
+ - `FocalLoss`: gamma=2.0
65
+ - `train_one_epoch()`: AMP + gradient accumulation (effective batch=32)
66
+ - `extract_embeddings()` / `extract_embeddings_with_tta()`: TTA 推論
67
+ - `compute_k_reciprocal_rerank()`: k-reciprocal re-ranking
68
+ - `generate_submissions()`: 5種類の submission 生成 (baseline, TTA, rerank, calibrated, ensemble)
69
+
70
+ ### 次のステップ
71
+
72
+ - GPU 空き次第 exp=000 を実行
73
+ - LB スコアを確認し exp001 と比較
74
+
75
+ ## exp002_public_baseline デバッグ実行・通常モード開始
76
+
77
+ ### デバッグ実行 (debug=true)
78
+ - albumentations v2.0 API 変更に対応 (ShiftScaleRotate→Affine, GaussNoise, CoarseDropout 等)
79
+ - debugモードで3エポック早期終了を実装
80
+ - 3エポック正常完了: Loss 17.58→13.65→8.35, Accuracy 0%→3.5%→30.3%
81
+ - 5種類の submission.csv 正常生成
82
+
83
+ ### 通常モード実行開始
84
+ - `uv run python -m experiments.exp002_public_baseline.run exp=000` をバックグラウンドで実行開始 (18:04)
85
+ - 25エポック、wandb run: `exp002_public_baseline/000` (bid9iijn)
86
+
87
+ ## CLAUDE.md ルール追加: 実行中プログラムの追跡
88
+
89
+ ユーザーの指示により、長時間実行するプログラムの状態を TODO.md で追跡する標準ルールを追加。
90
+ - CLAUDE.md: 「実行中プログラムの追跡」ルールを追加
91
+ - TODO.md: 「現在実行中」セクションを新設
92
+
93
+ ## exp003_eva02_baseline 実装
94
+
95
+ 公開ノートブック ([lakhindarpal/jaguar-re-identification-challenge](https://www.kaggle.com/code/lakhindarpal/jaguar-re-identification-challenge)) をプロジェクトフレームワークに統合。
96
+
97
+ ### exp002 との主な差分
98
+
99
+ | 項目 | exp002 (公開NB #1) | exp003 (今回) |
100
+ |------|-------------------|--------------|
101
+ | Backbone | MegaDescriptor-B-224 (88M) | EVA-02 Large 448px (~300M) |
102
+ | Image size | 224 | 448 |
103
+ | Pooling | Global Average | GeM (Generalized Mean) |
104
+ | ArcFace | Sub-center (k=2) | Standard |
105
+ | Loss | Focal Loss (gamma=2.0) | CrossEntropy |
106
+ | Augmentation | albumentations (多数) | torchvision (基本的) |
107
+ | Neck | 2層 MLP + BN + PReLU | BN のみ |
108
+ | Class Balancing | WeightedRandomSampler | なし |
109
+ | Post-processing | TTA + rerank + calibration + ensemble | TTA + Query Expansion + rerank |
110
+ | Epochs | 25 | 10 |
111
+ | LR | 2e-4 | 2e-5 |
112
+ | Effective batch | 32 | 16 |
113
+ | Scheduler | Cosine + linear warmup | CosineAnnealingLR (warmup なし) |
114
+
115
+ ### 実施内容
116
+
117
+ | ファイル | 操作 | 内容 |
118
+ |---|---|---|
119
+ | `experiments/exp003_eva02_baseline/run.py` | 新規作成 | メイン実装 (~550行) |
120
+ | `experiments/exp003_eva02_baseline/config.yaml` | 新規作成 | Hydra 設定 |
121
+ | `experiments/exp003_eva02_baseline/exp/000.yaml` | 新規作成 | EVA-02 Large デフォルト設定 |
122
+ | `experiments/exp003_eva02_baseline/SESSION_NOTES.md` | 新規作成 | セッション記録 |
123
+ | `docs/experiments.md` | 修正 | exp003 セクション追加 |
124
+ | `TODO.md` | 修正 | exp003 タスク追加 |
125
+
126
+ ### 主要コンポーネント
127
+
128
+ - `GeM`: Generalized Mean Pooling (学習可能パラメータ p)
129
+ - `ArcFaceLayer`: Standard ArcFace head
130
+ - `EVAReIDModel`: EVA-02 Large + GeM + BN + ArcFace (ViT 出力の reshape + GeM 対応)
131
+ - `query_expansion()`: top-k 近傍の平均で embedding 更新
132
+ - `JaguarDataset` / `JaguarTestDataset`: torchvision transforms + PIL ベース
133
+ - `train_one_epoch()`: AMP + gradient accumulation (CosineAnnealingLR)
134
+ - `generate_submissions()`: 5種類の submission 生成 (baseline, TTA, QE, rerank, ensemble)
135
+
136
+ ### デバッグ実行結果
137
+
138
+ 3エポック正常完了: Loss 11.79→10.63→8.96, Accuracy 4.85%→7.93%→18.34%
139
+ 5種類の submission.csv 正常生成 (baseline, TTA, QE, rerank, ensemble)
140
+
141
+ ### 次のステップ
142
+
143
+ - GPU 空き次第 exp=000 を通常実行
144
+ - LB スコア確認・exp002 との比較
145
+
146
+ ## exp002_public_baseline 通常モード完了・LBサブミット
147
+
148
+ ### 学習結果
149
+ - 25エポック完了: train_accuracy=99.42%, loss=0.034
150
+ - wandb run: `exp002_public_baseline/000` (bid9iijn)
151
+
152
+ ### LBスコア
153
+ - **Public LB: 0.781** (ensemble: 0.4*TTA + 0.35*rerank + 0.25*calibrated)
154
+
155
+ ## exp003_eva02_baseline 通常モード完了・LBサブミット
156
+
157
+ ### 学習結果 (10エポック)
158
+
159
+ | Epoch | Loss | Accuracy |
160
+ |-------|------|----------|
161
+ | 1 | 15.31 | 0.16% |
162
+ | 2 | 9.50 | 17.97% |
163
+ | 3 | 6.00 | 38.48% |
164
+ | 4 | 3.99 | 54.92% |
165
+ | 5 | 2.78 | 69.66% |
166
+ | 6 | 1.91 | 76.90% |
167
+ | 7 | 1.54 | 79.86% |
168
+ | 8 | 1.23 | 84.62% |
169
+ | 9 | 1.11 | 85.99% |
170
+ | 10 | 0.92 | 88.69% |
171
+
172
+ ### Submission 結果
173
+
174
+ | Submission | Mean | Std |
175
+ |-----------|------|-----|
176
+ | baseline | 0.5034 | 0.1043 |
177
+ | TTA | 0.5034 | 0.1045 |
178
+ | QE (top_k=3) | 0.5033 | 0.1083 |
179
+ | rerank | 0.5027 | 0.0773 |
180
+ | ensemble | 0.5032 | 0.0971 |
181
+
182
+ ### LBスコア
183
+ - **Public LB: 0.921** (ensemble: 0.4*TTA + 0.3*QE + 0.3*rerank)
184
+ - exp002 (0.781) から +0.140 の大幅改善
185
+ - wandb run: `exp003_eva02_baseline/000` (s0k3gpx7)
186
+
187
+ ## kaggle-template の改良を反映
188
+
189
+ kaggle-template で追加された Claude Code 向け改良を本リポジトリに反映。
190
+
191
+ ### 実施内容
192
+
193
+ | ファイル | 操作 | 内容 |
194
+ |---|---|---|
195
+ | `CLAUDE.md` | 更新 | View実装の原則を削除、新禁止事項追加、Kaggleワークフローセクション追加 |
196
+ | `KAGGLE_DIRECTION.md` | 新規作成 | コンペ固有ワークフロー(Jaguar用に適応) |
197
+ | `survey/papers/README.md` + `.gitkeep` | 新規作成 | 論文調査ガイド |
198
+ | `survey/discussion/README.md` + `.gitkeep` | 新規作成 | ディスカッション定点観測ガイド |
199
+ | `competition/overview.md` | 新規作成 | EDA・データ概要テンプレート |
200
+ | `competition/related_competitions.md` | 新規作成 | 類似コンペ調査テンプレート |
201
+ | `experiments/exp000_sample/SESSION_NOTES.md` | 新規作成 | セッション記録テンプレート |
202
+ | `experiments/exp001_baseline/SESSION_NOTES.md` | 新規作成 | セッション記録(実験情報記入済み) |
203
+ | `docs/experiments.md` | 更新 | 知見集約形式に拡張(ベストスコア履歴、重要な知見等) |
204
+ | `.gitignore` | 更新 | ML モデルファイル、survey データを追加 |
205
+ | `README.md` | 更新 | 新構造、命名規則、関連ドキュメント等を追加 |
206
+ | `tests/.gitkeep` | 新規作成 | テストディレクトリ |
logs/Log_2026-02-11.md ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 開発ログ 2026-02-11
2
+
3
+ ## exp004_0938_optimal_blending 実装
4
+
5
+ 公開ノートブック ([sanidhyavijay24/jaguar-re-id-0-938-eva-02-optimal-blending](https://www.kaggle.com/code/sanidhyavijay24/jaguar-re-id-0-938-eva-02-optimal-blending)) をプロジェクトフレームワークに統合。
6
+
7
+ ### exp003 との主な差分
8
+
9
+ | 項目 | exp003 (LB 0.921) | exp004 (0.938 NB) |
10
+ |------|-------------------|-------------------|
11
+ | Neck (FC層) | backbone_dim → BN → FC(1024) → BN2 | backbone_dim → BN のみ (FC なし) |
12
+ | Normalize mean/std | ImageNet [0.485, 0.456, 0.406] / [0.229, 0.224, 0.225] | [0.481, 0.457, 0.408] / [0.268, 0.261, 0.275] |
13
+ | CLS トークン処理 | num_prefix_tokens で先頭除去 | if H*W != N: features[:, -(H*W):, :] |
14
+ | TTA | 別パスで抽出 → 平均 → normalize | バッチ内 flip: (feat + feat_flip) / 2 → normalize |
15
+ | Re-ranking | expansion-based k-reciprocal | Jaccard距離ベース k-reciprocal |
16
+ | rerank_lambda | 0.3 | 0.2 |
17
+ | ブレンディング | 0.4*TTA + 0.3*QE + 0.3*rerank | Optimal: 0.2*raw + 0.8*rerank |
18
+ | 類似度計算 | ペアごと (dot+1)/2 クリップ | NxN 行列一括計算 |
19
+ | ArcFace input dim | embedding_dim=1024 (FC後) | backbone_dim そのまま |
20
+
21
+ ### 実施内容
22
+
23
+ | ファイル | 操作 | 内容 |
24
+ |---|---|---|
25
+ | `experiments/exp004_0938_optimal_blending/run.py` | 新規作成 | メイン実装 (~550行) |
26
+ | `experiments/exp004_0938_optimal_blending/config.yaml` | 新規作成 | Hydra 設定 |
27
+ | `experiments/exp004_0938_optimal_blending/exp/000.yaml` | 新規作成 | 0.938 NB デフォルト設定 |
28
+ | `experiments/exp004_0938_optimal_blending/SESSION_NOTES.md` | 新規作成 | セッション記録 |
29
+ | `docs/experiments.md` | 修正 | exp004 セクション追加 |
30
+ | `TODO.md` | 修正 | exp004 タスク追加 |
31
+
32
+ ### 主要コンポーネント
33
+
34
+ - `EVAJaguarModel`: EVA-02 Large + GeM + BN → ArcFace (FC層なし)
35
+ - `extract_features_batch()`: バッチ内 flip TTA
36
+ - `k_reciprocal_rerank()`: Jaccard 距離ベース k-reciprocal re-ranking
37
+ - `query_expansion()`: NxN 行列ベース
38
+ - `compute_similarity_matrix()` / `lookup_pair_similarities()`: NxN 行列一括計算
39
+ - `generate_submissions()`: 5種類の submission (baseline, TTA, rerank, optimal_blend, main)
40
+
41
+ ### デバッグ実行結果
42
+
43
+ 3エポック正常完了: Loss 10.44→4.70→2.94, Accuracy 7.4%→42%→68.4%
44
+ 5種類の submission.csv 正常生成 (baseline, TTA, rerank, optimal_blend, main)
45
+
46
+ ### 通常モード実行結果
47
+
48
+ - コマンド: `uv run python -m experiments.exp004_0938_optimal_blending.run exp=000`
49
+ - 開始: 01:29, 完了: 02:25
50
+ - wandb run: `exp004_0938_optimal_blending/000` ([link](https://wandb.ai/nawta1998/jaguar-re-identification/runs/qq901bm5))
51
+
52
+ #### エポック別結果
53
+
54
+ | Epoch | Loss | Accuracy |
55
+ |-------|------|----------|
56
+ | 1 | 10.4424 | 7.42% |
57
+ | 2 | 4.1012 | 45.21% |
58
+ | 3 | 2.3430 | 68.73% |
59
+ | 4 | 1.3775 | 79.75% |
60
+ | 5 | 0.7867 | 87.50% |
61
+ | 6 | 0.4756 | 92.70% |
62
+ | 7 | 0.3151 | 95.42% |
63
+ | 8 | 0.2252 | 97.04% |
64
+ | 9 | 0.1717 | 97.93% |
65
+ | 10 | 0.1355 | 98.47% |
66
+
67
+ #### Submission 統計
68
+
69
+ | Submission | Mean | Std |
70
+ |-----------|------|-----|
71
+ | Baseline (raw cosine) | 0.0126 | 0.2136 |
72
+ | TTA (in-batch flip) | 0.0127 | 0.2142 |
73
+ | Jaccard Re-ranking | 0.0160 | 0.2034 |
74
+ | Optimal Blend (20% raw + 80% reranked) | 0.0153 | 0.2052 |
75
+
76
+ メイン提出: `submission.csv` = optimal_blend のコピー (137,270 行)
77
+
78
+ ### LB 提出結果
79
+
80
+ **Public LB: 0.946** (exp003 0.921 → +0.025、元 NB 0.938 も超過)
81
+
82
+ 初回提出は SubmissionStatus.ERROR: cosine similarity が [-1, 1] のまま出力されていたため。
83
+ `lookup_pair_similarities()` に `np.clip((raw + 1) / 2, 0, 1)` マッピングを追加して修正。
84
+
85
+ ### 次のステップ
86
+
87
+ - 他の submission (baseline, TTA, rerank) も個別に提出してどの後処理が効いているか確認
88
+ - さらなるスコア改善の検討
89
+
90
+ ## exp005_pseudo_labeling 実装
91
+
92
+ 公開ノートブック ([kawaharataishi/pseudo-labeling](https://www.kaggle.com/code/kawaharataishi/pseudo-labeling/notebook)) をプロジェクトフレームワークに統合。
93
+
94
+ ### exp004 との主な差分
95
+
96
+ | 項目 | exp004 (LB 0.946) | exp005 (Pseudo-Labeling) |
97
+ |------|-------------------|--------------------------|
98
+ | 学習フロー | 訓練データのみで10エポック | exp004モデルロード → PL生成 → 結合データで5エポック再学習 |
99
+ | 訓練データ | train.csv のみ | train.csv + pseudo_labels (テスト画像の高確信度予測) |
100
+ | Augmentation | HFlip + Affine + ColorJitter + RandomErasing | + SharpenTransform(p=0.3) |
101
+ | LR | 2e-5 | 1e-5 (fine-tuning用に低め) |
102
+ | エポック | 10 | 5 (fine-tuning用に少なめ) |
103
+
104
+ ### 実施内容
105
+
106
+ | ファイル | 操作 | 内容 |
107
+ |---|---|---|
108
+ | `experiments/exp005_pseudo_labeling/run.py` | 新規作成 | メイン実装 (~650行) |
109
+ | `experiments/exp005_pseudo_labeling/config.yaml` | 新規作成 | Hydra 設定 |
110
+ | `experiments/exp005_pseudo_labeling/exp/000.yaml` | 新規作成 | デフォルト設定 |
111
+ | `experiments/exp005_pseudo_labeling/SESSION_NOTES.md` | 新規作成 | セッション記録 |
112
+ | `docs/experiments.md` | 修正 | exp005 セクション追加 |
113
+ | `TODO.md` | 修正 | exp005 タスク追加 |
114
+
115
+ ### 主要コンポーネント
116
+
117
+ - `SharpenTransform`: PIL.ImageFilter.SHARPEN を確率的に適用
118
+ - `generate_pseudo_labels()`: テスト画像の高確信度予測を擬似ラベルとして生成
119
+ - `finetune_with_pseudo_labels()`: train + pseudo で fine-tuning
120
+ - `load_base_model()`: exp004 best_model.pth をロード
121
+ - exp004 から流用: EVAJaguarModel, GeM, ArcFaceLayer, extract_features_batch, generate_submissions 等
122
+
123
+ ### 通常モード実行結果
124
+
125
+ - コマンド: `uv run python -m experiments.exp005_pseudo_labeling.run exp=000`
126
+ - 開始: 03:07, 完了: 03:41
127
+ - wandb run: `exp005_pseudo_labeling/000` ([link](https://wandb.ai/nawta1998/jaguar-re-identification/runs/qfmba3ct))
128
+
129
+ #### 擬似ラベル生成結果
130
+
131
+ - テスト画像: 371枚
132
+ - threshold 0.90 以上: 364枚 (98.1%)
133
+ - Confidence: min=0.9149, mean=0.9996, max=1.0000
134
+
135
+ #### Fine-tuning エポック別結果
136
+
137
+ 結合データ: 1,895 (train) + 364 (pseudo) = 2,259件
138
+
139
+ | Epoch | Loss | Accuracy |
140
+ |-------|------|----------|
141
+ | 1 | 0.3241 | 96.01% |
142
+ | 2 | 0.2828 | 97.12% |
143
+ | 3 | 0.1210 | 98.32% |
144
+ | 4 | **0.0731** | **99.20%** |
145
+ | 5 | 0.0815 | 98.71% |
146
+
147
+ ベストモデル: Epoch 4 (Loss: 0.0731)
148
+
149
+ #### Submission 統計
150
+
151
+ | Submission | Mean | Std |
152
+ |-----------|------|-----|
153
+ | Baseline (raw cosine) | 0.5059 | 0.1087 |
154
+ | TTA (in-batch flip) | 0.5059 | 0.1088 |
155
+ | Jaccard Re-ranking | 0.5078 | 0.1019 |
156
+ | Optimal Blend (20% raw + 80% reranked) | 0.5074 | 0.1031 |
157
+
158
+ メイン提出: `submission.csv` = optimal_blend のコピー (137,270 行)
159
+
160
+ ### LB 提出結果
161
+
162
+ **Public LB: 0.937** (exp004 0.946 → **-0.009** 悪化)
163
+
164
+ Pseudo-Labeling が逆効果。similarity Mean が 0.50 付近に集中(exp004 では 0.01 付近)しており、embedding の識別力が低下した可能性。
165
+
166
+ ## アンサンブル (exp003 + exp004 + exp005)
167
+
168
+ 各実験のメイン submission を使って4種類のアンサンブルを生成。
169
+
170
+ ### 訓練エポック数
171
+
172
+ | 実験 | エポック数 | LB |
173
+ |------|----------|-----|
174
+ | exp003 | 10 | 0.921 |
175
+ | exp004 | 10 | 0.946 |
176
+ | exp005 | exp004 + 5ep fine-tune | 0.937 |
177
+
178
+ ### 生成したアンサンブル
179
+
180
+ | 手法 | 重み (003/004/005) | Mean | Std | LB |
181
+ |------|-------------------|------|-----|-----|
182
+ | Equal Average | 1/3, 1/3, 1/3 | 0.5061 | 0.0991 | 未提出 |
183
+ | Weighted | 0.2, 0.5, 0.3 | 0.5067 | 0.1001 | 未提出 (提出制限) |
184
+ | exp004-heavy | 0.1, 0.7, 0.2 | 0.5072 | 0.1011 | 未提出 (提出制限) |
185
+ | Rank Average | rank 平均 | 0.4981 | 0.2439 | **0.937** |
186
+
187
+ ### 考察
188
+
189
+ - Rank Average (0.937) は exp004 単体 (0.946) を下回った
190
+ - exp003 (LB 0.921) の混入がスコアを引き下げている可能性
191
+
192
+ ## アンサンブル (exp004 + exp005)
193
+
194
+ exp003 を除き、exp004 + exp005 のみの2モデルアンサンブルを試行。
195
+
196
+ | 手法 | 重み (004/005) | LB |
197
+ |------|---------------|-----|
198
+ | Equal Average | 0.5/0.5 | 0.947 |
199
+ | Weighted | **0.7/0.3** | **0.948** |
200
+ | Weighted | 0.8/0.2 | 0.947 |
201
+ | Rank Average | rank 平均 | 0.944 |
202
+
203
+ **ベスト: Weighted 0.7/0.3 → LB 0.948** (exp004 単体 0.946 → +0.002)
204
+
205
+ exp005 (Pseudo-Labeling) は単体では悪化したが、exp004 とのアンサンブルでは +0.002 の改善に貢献。多様性が有効に機能。
logs/Log_2026-02-12.md ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 開発ログ 2026-02-12
2
+
3
+ ## exp006_dinov2 実装
4
+
5
+ ### 実装内容
6
+ - exp004_0938_optimal_blending をベースに DINOv2 backbone 版を実装
7
+ - 4つの AI モデル (Opus 4.6, Sonnet/Opus 4.5, Codex 5.3, Codex 5.2) の設計レビューを統合
8
+
9
+ ### 変更点 (exp004 → exp006)
10
+ | 項目 | exp004 | exp006 |
11
+ |------|--------|--------|
12
+ | Backbone | `eva02_large_patch14_448` | `vit_large_patch14_reg4_dinov2.lvd142m` |
13
+ | Image size | 448 | 518 |
14
+ | Feature dim | 1024 | 1024 (同一) |
15
+ | Normalize | [0.481,0.457,0.408]/[0.268,0.261,0.275] | ImageNet標準 |
16
+ | CLS除去 | `features[:, -(H*W):, :]` | `features[:, num_prefix:, :]` |
17
+ | dynamic_img_size | なし | True |
18
+ | Model class名 | EVAJaguarModel | DINOv2JaguarModel |
19
+
20
+ ### 作成ファイル
21
+ - `experiments/exp006_dinov2/run.py`: メイン実行スクリプト
22
+ - `experiments/exp006_dinov2/config.yaml`: Hydra 設定
23
+ - `experiments/exp006_dinov2/exp/000.yaml`: DINOv2 デフォルト設定
24
+ - `experiments/exp006_dinov2/SESSION_NOTES.md`: セッションノート
25
+
26
+ ### デバッグモード結果
27
+ - 3エポック正常完了
28
+ - Epoch 1: Loss 9.2741, Acc 6.57%
29
+ - Epoch 2: Loss 8.4287, Acc 21.16%
30
+ - Epoch 3: Loss 4.4287, Acc 51.16%
31
+ - Loss は低下傾向、学習は正常に動作
32
+ - 5種類の submission.csv 生成を確認
33
+
34
+ ### 通常モード結果
35
+ - 10エポック完了 (16:02-16:55, 約53分)
36
+ - Best model: Epoch 9 (Loss 0.3982, Acc 95.14%)
37
+ - Epoch 10: Loss 0.4295, Acc 94.77% (若干の過学習傾向)
38
+ - 5種類の submission.csv 生成完了
39
+ - best_model.pth: 1.2GB
40
+ - wandb: https://wandb.ai/nawta1998/jaguar-re-identification/runs/oekz88cj
41
+
42
+ ### エポック推移
43
+ | Epoch | Loss | Accuracy |
44
+ |-------|------|----------|
45
+ | 1 | 14.3756 | 2.38% |
46
+ | 2 | 7.1063 | 30.44% |
47
+ | 3 | 3.9048 | 55.18% |
48
+ | 4 | 2.4275 | 71.25% |
49
+ | 5 | 1.5750 | 80.02% |
50
+ | 6 | 1.0837 | 85.89% |
51
+ | 7 | 0.7684 | 89.48% |
52
+ | 8 | 0.5429 | 93.18% |
53
+ | 9 | 0.3982 | 95.14% |
54
+ | 10 | 0.4295 | 94.77% |
55
+
56
+ ## exp006_dinov2 収束分析 & 20ep 延長
57
+
58
+ ### 収束分析
59
+ - exp006 ep8→9 で Loss 27% 改善 (0.543→0.398)、まだ急降下中
60
+ - ep10 の Loss 悪化 (0.398→0.430) は CosineAnnealingLR T_max=10 で LR がほぼ0 (5.87e-07) になったため
61
+ - exp004 は 10ep で Loss 0.136 に収束、DINOv2 はまだ 0.398 → 収束が 2ep 以上遅い
62
+ - **結論: DINOv2 は 10ep では未収束、20ep に延長が必要**
63
+
64
+ ### チェックポイント再開の実装
65
+ - `run.py` に `resume_from`, `start_epoch` パラメータ追加
66
+ - `exp/001.yaml` 作成: epochs=20, resume_from=exp000/best_model.pth, start_epoch=10
67
+ - CosineAnnealingLR T_max=20 で LR スケジュール延長
68
+
69
+ ### exp=001 結果 (20ep, ep10から再開)
70
+
71
+ | Epoch | Loss | Accuracy | Best? |
72
+ |-------|------|----------|-------|
73
+ | 11 | 0.4197 | 94.40% | Yes |
74
+ | 12 | 0.3720 | 95.24% | Yes |
75
+ | 13 | 0.2581 | 96.62% | Yes |
76
+ | 14 | 0.2023 | 97.09% | Yes |
77
+ | 15 | 0.1293 | 97.83% | Yes |
78
+ | 16 | 0.1496 | 98.41% | |
79
+ | 17 | 0.1350 | 97.99% | |
80
+ | 18 | 0.1142 | 98.41% | Yes |
81
+ | 19 | **0.0827** | **98.94%** | **Best** |
82
+ | 20 | 0.1606 | 98.15% | |
83
+
84
+ - Best: Epoch 19 (Loss 0.0827, Acc 98.94%)
85
+ - 学習時間: 約56分 (17:31-18:27)
86
+ - wandb: https://wandb.ai/nawta1998/jaguar-re-identification/runs/q8wi2ngh
87
+
88
+ ### exp004 vs exp006 比較 (training metrics)
89
+ | | exp004 (EVA-02, 10ep) | exp006/001 (DINOv2, 20ep) |
90
+ |--|----------------------|--------------------------|
91
+ | Best Loss | 0.1355 | **0.0827** |
92
+ | Best Acc | 98.47% | **98.94%** |
93
+
94
+ ### exp006 LB 提出結果
95
+ - exp=000 (10ep): **LB 0.897**
96
+ - exp=001 (20ep): **LB 0.925**
97
+ - training metrics は exp004 を上回ったが、LB は大幅に下回る (0.925 vs 0.946)
98
+ - DINOv2 は training で過学習気味の可能性
99
+
100
+ ## exp003/exp004 収束分析 & 20ep 延長
101
+
102
+ ### 収束分析結果
103
+ - **exp003 (10ep)**: 未収束。ep9→10 で Loss -18% 改善中。Best Loss 0.9157, Acc 88.69%
104
+ - **exp004 (10ep)**: LR 枯渇。CosineAnnealing T_max=10 で LR ≈0。ep9→10 は -1.2% 改善のみ
105
+ - 両方とも T_max=20 に拡張して学習延長が有効と判断
106
+
107
+ ### チェックポイント再開実装
108
+ - exp003/run.py, exp004/run.py に `resume_from`, `start_epoch` パラメータ追加
109
+ - exp003/exp/001.yaml, exp004/exp/001.yaml 作成 (epochs=20, start_epoch=10)
110
+ - exp003 デバッグモード確認済み: ep11-13 で Loss 0.9157→0.7959, Acc 88.69%→90.01%
111
+
112
+ ### exp003 exp=001 通常モード結果 (20ep, ep10から再開)
113
+
114
+ | Epoch | Loss | Accuracy | Best? |
115
+ |-------|------|----------|-------|
116
+ | 11 | 1.0618 | 85.94% | Yes |
117
+ | 12 | 1.0464 | 86.89% | Yes |
118
+ | 13 | 0.7721 | 90.06% | Yes |
119
+ | 14 | 0.6287 | 91.86% | Yes |
120
+ | 15 | 0.5281 | 94.29% | Yes |
121
+ | 16 | 0.3571 | 95.61% | Yes |
122
+ | 17 | 0.3504 | 96.51% | Yes |
123
+ | 18 | 0.3216 | 96.83% | Yes |
124
+ | 19 | 0.3793 | 95.72% | |
125
+ | 20 | **0.3035** | **96.78%** | **Best** |
126
+
127
+ - Best: Epoch 20 (Loss 0.3035, Acc 96.78%)
128
+ - 学習時間: 約52分 (19:09-20:01)
129
+ - wandb: https://wandb.ai/nawta1998/jaguar-re-identification/runs/at1njwj2
130
+ - 10ep→20ep で Loss 0.9157→0.3035 (67%��善), Acc 88.69%→96.78% (+8.09pt)
131
+ - **LB 0.913** (10ep LB 0.921 より悪化 -0.008)
132
+ - training metrics は大幅改善だが LB は悪化 → 過学習の兆候
133
+
134
+ ### exp004 exp=001 通常モード結果 (20ep, ep10から再開)
135
+
136
+ | Epoch | Loss | Accuracy | Best? |
137
+ |-------|------|----------|-------|
138
+ | 11 | 0.2118 | 97.30% | Yes |
139
+ | 12 | 0.1648 | 97.73% | Yes |
140
+ | 13 | 0.0914 | 98.84% | Yes |
141
+ | 14 | 0.1064 | 98.78% | |
142
+ | 15 | 0.0948 | 98.47% | |
143
+ | 16 | 0.0677 | 98.73% | Yes |
144
+ | 17 | 0.0687 | 99.00% | |
145
+ | 18 | 0.0518 | 99.26% | Yes |
146
+ | 19 | **0.0481** | **99.42%** | **Best** |
147
+ | 20 | 0.0560 | 99.00% | |
148
+
149
+ - Best: Epoch 19 (Loss 0.0481, Acc 99.42%)
150
+ - 学習時間: 約52分 (20:06-20:58)
151
+ - wandb: https://wandb.ai/nawta1998/jaguar-re-identification/runs/7xgrxohi
152
+ - 10ep→20ep で Loss 0.1355→0.0481 (64%改善), Acc 98.47%→99.42% (+0.95pt)
153
+
154
+ ### exp004 10ep vs 20ep 比較
155
+ | | exp004/000 (10ep) | exp004/001 (20ep) |
156
+ |--|-------------------|-------------------|
157
+ | Best Loss | 0.1355 | **0.0481** |
158
+ | Best Acc | 98.47% | **99.42%** |
159
+ | LB | **0.946** | 0.945 (-0.001) |
160
+
161
+ ### 20ep 延長学習の総括
162
+ | 実験 | 10ep LB | 20ep LB | 差分 |
163
+ |------|---------|---------|------|
164
+ | exp003 (EVA-02 baseline) | 0.921 | 0.913 | **-0.008** |
165
+ | exp004 (optimal blending) | **0.946** | 0.945 | **-0.001** |
166
+ | exp006 (DINOv2) | 0.897 | 0.925 | +0.028 |
167
+
168
+ - **結論**: exp003/exp004 は 10ep で十分収束しており、20ep は過学習
169
+ - exp006 (DINOv2) のみ 20ep 延長が有効だった(収束が遅いため)
170
+ - training metrics の改善 ≠ LB スコアの改善(汎化性能の観点で重要な知見)
171
+
172
+ ## exp004/exp006 アンサンブル検証
173
+
174
+ ### モデル間相関
175
+ | ペア | 相関係数 |
176
+ |------|----------|
177
+ | exp004-exp006 | 0.9412 |
178
+ | exp004-exp005 | 0.9639 |
179
+ | exp005-exp006 | 0.9305 |
180
+
181
+ - exp004-exp006 の相関 (0.941) は exp004-exp005 (0.964) より低い → 多様性が高く、アンサンブル効果が期待できる
182
+
183
+ ### 提出結果 (2-model: exp004 + exp006)
184
+ | アンサンブル | 重み (004/006) | LB |
185
+ |-------------|---------------|-----|
186
+ | exp004+006 w50/50 | 0.5/0.5 | 0.931 |
187
+ | exp004+006 w70/30 | 0.7/0.3 | 0.946 |
188
+ | **exp004+006 w80/20** | **0.8/0.2** | **0.947** |
189
+
190
+ ### 提出結果 (3-model: exp004 + exp005 + exp006)
191
+ | アンサンブル | 重み (004/005/006) | LB |
192
+ |-------------|-------------------|-----|
193
+ | 3-model w50/20/30 | 0.5/0.2/0.3 | 0.946 |
194
+ | 3-model w60/20/20 | 0.6/0.2/0.2 | 0.947 |
195
+ | **3-model w50/30/20** | **0.5/0.3/0.2** | **0.948** |
196
+
197
+ ### 参考: exp004 + exp005 (既存ベスト)
198
+ | アンサンブル | 重み (004/005) | LB |
199
+ |-------------|---------------|-----|
200
+ | **exp004+005 w70/30** | **0.7/0.3** | **0.948** (現ベスト) |
201
+
202
+ ### 分析
203
+ - exp004+exp006 w80/20 が LB 0.947 で 2-model ベスト(exp004+005 の 0.948 にわずかに届かず)
204
+ - 3-model w50/30/20 (LB 0.948) は現ベストと同等だが超えられず
205
+ - exp006 は重み 0.2 程度で混ぜると微改善、0.3 以上では悪化
206
+ - **結論: exp006 (DINOv2) の追加はスコア改善に寄与しない。現ベスト LB 0.948 維持**
logs/Log_2026-02-16.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Log 2026-02-16
2
+
3
+ ## exp007_improved_training 実装
4
+
5
+ ### 概要
6
+ exp004 (EVA-02 Large, 10ep, LB 0.946) をベースに、学習戦略を改善してモデル単体の性能向上を狙う実験を実装。
7
+
8
+ ### 実装した3つの改善
9
+ 1. **Layer-wise LR Decay** (`get_layer_id_for_eva02`, `build_optimizer_with_layerwise_lr`)
10
+ - EVA-02 Large: 24 transformer blocks
11
+ - Layer 割当: embed(0), blocks.0-23(1-24), fc_norm(25), head(26)
12
+ - LR = base_lr * decay_rate^(num_layers+2 - layer_id)
13
+ - lr_decay_rate=0.75, BN/bias は weight_decay=0
14
+
15
+ 2. **Linear Warmup + Cosine Decay** (`build_warmup_cosine_scheduler`)
16
+ - LambdaLR で per-step 実装
17
+ - warmup_steps = steps_per_epoch * warmup_epochs (default 1.0ep)
18
+ - cosine decay min_lr_ratio=0.005
19
+
20
+ 3. **EMA** (timm.utils.ModelEmaV2)
21
+ - decay=0.999
22
+ - optimizer.step() 後に ema_model.update(model)
23
+ - checkpoint に ema_state_dict 保存
24
+ - 推論時は EMA weights を使用
25
+
26
+ ### 作成ファイル
27
+ - `experiments/exp007_improved_training/run.py`
28
+ - `experiments/exp007_improved_training/config.yaml`
29
+ - `experiments/exp007_improved_training/exp/000.yaml`
30
+ - `experiments/exp007_improved_training/SESSION_NOTES.md`
31
+
32
+ ### デバッグモード動作確認
33
+ - 3エポック正常完了
34
+ - Layer-wise LR: 27 param groups (embed=1.13e-8 → head=2.0e-5)
35
+ - Warmup + Cosine: 正常動作確認
36
+ - EMA: "Loading EMA weights for inference" 確認
37
+ - submission.csv 5種類生成確認
38
+ - param group ソート修正 (alphabetical → numeric by layer_id)
39
+
40
+ ### 通常モード結果 (10ep)
41
+ - **Best Loss**: 4.4556 (vs exp004's 0.1355, 32倍悪化)
42
+ - **Final Accuracy**: 48.94% (vs exp004's 98.47%, 50pt低下)
43
+ - **Similarity scores**: Baseline=0.890, TTA=0.892, Rerank=0.832, Blend=0.844
44
+ - **原因**: lr_decay_rate=0.75 が aggressive すぎて backbone 層が十分学習できず
45
+ - LB 提出済み (2026-02-16 02:28)
46
+
47
+ ### 知見
48
+ - Layer-wise LR Decay で lr_decay_rate=0.75 は EVA-02 Large (24 blocks) には aggressive すぎる
49
+ - 最浅層の LR: 2e-5 × 0.75^26 ≈ 1.13e-8 → ほぼ学習しない
50
+ - 推奨: lr_decay_rate=0.9~0.95 程度に留めるべき
51
+ - Warmup + EMA の効果は lr_decay_rate の問題に埋もれて評価不可能
52
+
53
+ ## exp007 ハイパーパラメータ再実験
54
+
55
+ ### 実験設計
56
+ | Config | Layer-wise LR | decay_rate | 最浅層 LR | Warmup | EMA | 狙い |
57
+ |--------|--------------|------------|-----------|--------|-----|------|
58
+ | exp=001 | ON | 0.95 | 5.3e-6 | 1.0ep | ON | decay_rate 緩和で backbone 学習回復 |
59
+ | exp=002 | OFF | - | 2e-5 (全層同一) | 1.0ep | ON | Warmup+EMA のみの効果検証 |
60
+
61
+ ### exp=001 結果 (10ep, Layer-wise LR decay_rate=0.95 + Warmup + EMA)
62
+ - **Best Loss**: 0.3466 (at epoch 10)
63
+ - **Accuracy**: 95.56%
64
+ - **Similarity scores**: Baseline=0.826, TTA=0.827, Rerank=0.775, Blend=0.785
65
+ - Layer-wise LR: embed=5.29e-6 → head=2.0e-5 (0.95^26 ≈ 0.264)
66
+ - exp004 (Loss 0.1355, Acc 98.47%) より劣る → decay_rate=0.95 でも Layer-wise LR は有害
67
+ - LB 提出済み (2026-02-16)
68
+
69
+ ### exp=002 結果 (10ep, Warmup+EMA のみ, Layer-wise LR OFF)
70
+ - **Best Loss**: 0.1904 (at epoch 10)
71
+ - **Accuracy**: 97.83%
72
+ - **Similarity scores**: Baseline=0.776, TTA=0.777, Rerank=0.732, Blend=0.741
73
+ - 全層同一LR (2e-5) + Warmup(1ep) + EMA(0.999)
74
+ - exp004 (Loss 0.1355, Acc 98.47%) に迫るが及ばず
75
+ - LB 提出済み (2026-02-16)
76
+
77
+ ### 全結果比較
78
+ | Config | Layer-wise LR | Best Loss | Accuracy | Sim Baseline | Sim Blend |
79
+ |--------|--------------|-----------|----------|-------------|----------|
80
+ | exp=000 | ON (0.75) | 4.4556 | 48.94% | 0.890 | 0.844 |
81
+ | exp=001 | ON (0.95) | 0.3466 | 95.56% | 0.826 | 0.785 |
82
+ | exp=002 | OFF | 0.1904 | 97.83% | 0.776 | 0.741 |
83
+ | exp004 baseline | - | 0.1355 | 98.47% | 0.894 | 0.869 |
84
+
85
+ ### 知見
86
+ - **Layer-wise LR Decay は EVA-02 Large に対して無効〜有害**: decay_rate=0.95 でも Acc 95.56% で exp004 (98.47%) を下回る
87
+ - **Warmup + EMA のみ (exp=002)**: Loss 0.1904, Acc 97.83% と改善するが exp004 (Loss 0.1355) には及ばない
88
+ - **Similarity scores の逆転**: 学習品質が良い exp=002 (Loss 0.1904) の方が similarity が低い (0.776 vs exp=000 の 0.890)。EMA weights の影響で embedding 空間が変化している可能性
89
+ - **結論**: Layer-wise LR / Warmup / EMA の3改善はいずれも exp004 ベースラインを超えられず。他のアプローチに注力すべき
submissions/exp004/000/submission.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp004/000/submission_baseline.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp004/000/submission_optimal_blend.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp004/000/submission_rerank.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp004/000/submission_tta.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp005/000/submission.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp005/000/submission_baseline.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp005/000/submission_optimal_blend.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp005/000/submission_rerank.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp005/000/submission_tta.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp006/001/submission.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp006/001/submission_baseline.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp006/001/submission_optimal_blend.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp006/001/submission_rerank.csv ADDED
The diff for this file is too large to render. See raw diff
 
submissions/exp006/001/submission_tta.csv ADDED
The diff for this file is too large to render. See raw diff
 
weights/exp004_0938_optimal_blending/000/best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28f255cd6169e02a512efcf3fc92b542b82489d041d0fb38e96a3f3595021fd2
3
+ size 1216542886
weights/exp005_pseudo_labeling/000/best_model_finetuned.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd7d6149827e8643e0be38447e66eb3b23039b52614a1e010315f7d13548ca8b
3
+ size 1216547636
weights/exp006_dinov2/001/best_model.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:157ce23cf61f7c8de8d79333c1f4da8d0668e02e7101554370b290a4f33ba343
3
+ size 1217766959