HemanM commited on
Commit
c0a6a03
·
verified ·
1 Parent(s): 54f7978

Update watchdog.py

Browse files
Files changed (1) hide show
  1. watchdog.py +19 -1
watchdog.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  import torch
3
  import firebase_admin
4
  from firebase_admin import credentials, firestore
@@ -79,9 +80,26 @@ def retrain_model():
79
  optimizer.step()
80
  print(f"Epoch {epoch+1}: Loss = {loss.item():.4f}")
81
 
 
 
 
 
 
82
  os.makedirs("trained_model", exist_ok=True)
83
- model.save_pretrained("trained_model")
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  print("✅ EvoTransformer retrained and saved.")
86
 
87
  # Reload the updated model for summary + plot
 
1
  import os
2
+ import json
3
  import torch
4
  import firebase_admin
5
  from firebase_admin import credentials, firestore
 
80
  optimizer.step()
81
  print(f"Epoch {epoch+1}: Loss = {loss.item():.4f}")
82
 
83
+ # Simulate accuracy (replace this with actual eval in the future)
84
+ accuracy = 1.0 # Replace with real evaluation later
85
+
86
+ # Save accuracy to evolution log
87
+ log_path = "trained_model/evolution_log.json"
88
  os.makedirs("trained_model", exist_ok=True)
 
89
 
90
+ if os.path.exists(log_path):
91
+ with open(log_path, "r") as f:
92
+ history = json.load(f)
93
+ else:
94
+ history = []
95
+
96
+ history.append({"accuracy": accuracy})
97
+
98
+ with open(log_path, "w") as f:
99
+ json.dump(history, f)
100
+
101
+ # Save trained model
102
+ model.save_pretrained("trained_model")
103
  print("✅ EvoTransformer retrained and saved.")
104
 
105
  # Reload the updated model for summary + plot