Text Generation
Safetensors
Swedish
qwen3
File size: 1,433 Bytes
97d0285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import json
import math

import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter, LogLocator
losses = []
with open("models/losses.json", "r") as f:
    losses += json.load(f)

print(losses[8])

avglosses = []
iters = []

chunksize = 1
iter = 100

while iter + chunksize < len(losses):
    avg = 0
    for i in range(round(chunksize)):
        avg += losses[iter + i]
    avg = avg / round(chunksize)

    avglosses.append(avg)      # riktig loss, inte log(avg)
    iters.append(iter)         # riktigt iterationsnummer

    iter += round(chunksize)
    chunksize *= 1.01
    print(iter, avg)




fig, ax = plt.subplots()
ax.plot(iters, avglosses)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel("Iteration")
ax.set_ylabel("Träningsloss")

import numpy as np

# Sätt egna y-ticks baserat på datans faktiska min/max
ymin, ymax = min(avglosses), max(avglosses)
yticks = np.arange(math.floor(ymin*10)/10, math.ceil(ymax*10)/10 + 0.1, 0.1)
ax.set_yticks(yticks)
ax.yaxis.set_major_formatter(ScalarFormatter())
ax.yaxis.set_minor_formatter(plt.NullFormatter())  # slipp rörig minor-text
# Grid för både major och minor
ax.grid(True, which='major', linestyle='-', linewidth=0.7, alpha=0.7)
ax.grid(True, which='minor', linestyle=':', linewidth=0.5, alpha=0.4)



plt.tight_layout()
plt.title("Träningsloss för microbatch")
plt.show()
plt.close()