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