HemanM commited on
Commit
97d3ebe
·
verified ·
1 Parent(s): 79a0857

Update evo_architecture.py

Browse files
Files changed (1) hide show
  1. evo_architecture.py +13 -0
evo_architecture.py CHANGED
@@ -28,6 +28,7 @@ def mutate_genome(base_config, exploration_rate=0.5):
28
  config = base_config.copy()
29
  config["genome_id"] = str(uuid.uuid4())
30
  mutation_type = random.choice(["num_layers", "ffn_dim", "num_heads", "memory_enabled"])
 
31
  if mutation_type == "memory_enabled":
32
  config["memory_enabled"] = not config["memory_enabled"]
33
  else:
@@ -35,8 +36,20 @@ def mutate_genome(base_config, exploration_rate=0.5):
35
  change = int((max_val - min_val) * exploration_rate)
36
  delta = random.randint(-change, change)
37
  config[mutation_type] = max(min_val, min(max_val, config[mutation_type] + delta))
 
 
 
 
 
 
 
 
 
 
 
38
  return config
39
 
 
40
  def log_genome(config, score=None):
41
  row = [
42
  config.get("genome_id", ""),
 
28
  config = base_config.copy()
29
  config["genome_id"] = str(uuid.uuid4())
30
  mutation_type = random.choice(["num_layers", "ffn_dim", "num_heads", "memory_enabled"])
31
+
32
  if mutation_type == "memory_enabled":
33
  config["memory_enabled"] = not config["memory_enabled"]
34
  else:
 
36
  change = int((max_val - min_val) * exploration_rate)
37
  delta = random.randint(-change, change)
38
  config[mutation_type] = max(min_val, min(max_val, config[mutation_type] + delta))
39
+
40
+ # ✅ Fix: Ensure embed_dim is divisible by num_heads
41
+ embed_dim = 512 # Your hardcoded d_model
42
+ if config["num_heads"] > embed_dim:
43
+ config["num_heads"] = max(1, embed_dim // 64) # fallback
44
+ while embed_dim % config["num_heads"] != 0:
45
+ config["num_heads"] -= 1
46
+ if config["num_heads"] <= 0:
47
+ config["num_heads"] = 1
48
+ break
49
+
50
  return config
51
 
52
+
53
  def log_genome(config, score=None):
54
  row = [
55
  config.get("genome_id", ""),