kgrabko commited on
Commit
72c8351
·
verified ·
1 Parent(s): cf7c619

Upload plot_loss.py

Browse files
Files changed (1) hide show
  1. plot_loss.py +63 -0
plot_loss.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==============================================================================
2
+ # COPYRIGHT (C) 2025 KONSTANTIN VLADIMIROVICH GRABKO. ALL RIGHTS RESERVED.
3
+ # PATENT PENDING | CMS MANHATTAN JIRACK TECHNOLOGY
4
+ #
5
+ # This software is licensed under the Commercial License Agreement V.1.2.
6
+ # Any use, modification, or distribution of this code requires compliance with
7
+ # the terms found in the LICENSE.md file in the root directory.
8
+ #
9
+ # NO PATENTING RIGHTS: Users are strictly prohibited from filing patent claims
10
+ # based on the BRE or SWA architectures disclosed herein.
11
+ # Contact: grabko@cmsmanhattan.com | +1 (516) 777-0945
12
+ # ==============================================================================
13
+
14
+
15
+ import matplotlib.pyplot as plt
16
+ import re
17
+ import os
18
+
19
+ LOG_FILE = "fine_tune_pile.log"
20
+ OUTPUT_IMAGE = "loss_chart.png"
21
+
22
+ def plot_loss():
23
+ if not os.path.exists(LOG_FILE):
24
+ print(f"Файл {LOG_FILE} не найден.")
25
+ return
26
+
27
+ steps = []
28
+ losses = []
29
+
30
+ # Регулярное выражение для поиска шага и лосса
31
+ pattern = re.compile(r"Шаг (\d+).*Loss: (\d+\.\d+)")
32
+
33
+ with open(LOG_FILE, "r") as f:
34
+ for line in f:
35
+ match = pattern.search(line)
36
+ if match:
37
+ steps.append(int(match.group(1)))
38
+ losses.append(float(match.group(2)))
39
+
40
+ if not steps:
41
+ print("Данные для графика пока не найдены в логе.")
42
+ return
43
+
44
+ plt.figure(figsize=(10, 6))
45
+ plt.plot(steps, losses, label='Raw Loss', alpha=0.3, color='blue')
46
+
47
+ # Скользящее среднее для сглаживания
48
+ if len(losses) > 10:
49
+ window = 10
50
+ smooth_loss = [sum(losses[i:i+window])/window for i in range(len(losses)-window)]
51
+ plt.plot(steps[window:], smooth_loss, label='Smooth Loss (EMA)', color='red', linewidth=2)
52
+
53
+ plt.xlabel('Step')
54
+ plt.ylabel('Loss')
55
+ plt.title('JiRack 1B Training Progress')
56
+ plt.legend()
57
+ plt.grid(True, linestyle='--', alpha=0.6)
58
+
59
+ plt.savefig(OUTPUT_IMAGE)
60
+ print(f"График сохранен в {OUTPUT_IMAGE}")
61
+
62
+ if __name__ == "__main__":
63
+ plot_loss()