Keeby-smilyai commited on
Commit
f6a808f
·
verified ·
1 Parent(s): e0790fc

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +32 -0
utils.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # utils.py
2
+
3
+ ARCH_ANALOGIES = {
4
+ "cnn": "🍲 CNN is like a sieve — strains local patterns from your data broth, layer by layer.",
5
+ "rnn": "⏲️ RNN is your slow-simmer pot — remembers earlier flavors to enrich the final dish.",
6
+ "transformer": "🌡️ Transformer is your sous-vide — precise, parallel, deeply flavorful at every layer."
7
+ }
8
+
9
+ def get_auto_hyperparams(arch_type, num_layers):
10
+ """Auto-Seasoning™ — smart defaults based on architecture and depth"""
11
+ base_config = {
12
+ "cnn": {"lr": 1e-3, "epochs": 3, "batch": 16},
13
+ "rnn": {"lr": 5e-4, "epochs": 4, "batch": 8},
14
+ "transformer": {"lr": 3e-4, "epochs": 3, "batch": 4}
15
+ }
16
+
17
+ config = base_config.get(arch_type, base_config["transformer"])
18
+
19
+ # Adjust for layer depth
20
+ if num_layers > 8:
21
+ config["lr"] *= 0.6
22
+ config["epochs"] += 2
23
+ config["batch"] = max(2, config["batch"] // 2)
24
+ elif num_layers < 4:
25
+ config["lr"] *= 1.3
26
+ config["batch"] = min(32, config["batch"] * 2)
27
+
28
+ return {
29
+ "learning_rate": round(config["lr"], 6),
30
+ "epochs": config["epochs"],
31
+ "batch_size": config["batch"]
32
+ }