Simple log functions
This commit is contained in:
parent
6daa8ec46c
commit
007c96e91b
1 changed files with 15 additions and 0 deletions
15
log.py
Normal file
15
log.py
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
from tinygrad.nn.state import safe_save
|
||||||
|
import csv
|
||||||
|
import os
|
||||||
|
|
||||||
|
def logLoss(step, loss):
|
||||||
|
path = "loss.csv"
|
||||||
|
exists = os.path.isfile(path)
|
||||||
|
with open(path, mode='a', newline='') as f:
|
||||||
|
writer = csv.writer(f)
|
||||||
|
if not exists:
|
||||||
|
writer.writerow(['step', 'loss'])
|
||||||
|
writer.writerow([step, float(loss)])
|
||||||
|
|
||||||
|
def logModel(step,stateDict):
|
||||||
|
safe_save(stateDict, f"gpt_{step}.safetensors")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue