Simple log functions
This commit is contained in:
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")
|
||||||
Reference in New Issue
Block a user