-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_model_params.py
More file actions
31 lines (25 loc) · 948 Bytes
/
verify_model_params.py
File metadata and controls
31 lines (25 loc) · 948 Bytes
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
import sys
import os
import torch
# Add project root to path
sys.path.append(os.getcwd())
from train import get_config
def count_parameters(model):
return sum(p.numel() for p in model.parameters() if p.requires_grad)
def verify_params():
models = ["neon167", "neon183", "neon184"]
print(f"{'Model':<10} | {'Config d_ff':<12} | {'Parameters':>12}")
print("-" * 40)
for m_name in models:
try:
cfg = get_config(m_name)
# Import dynamically
module = __import__(f"models.{m_name}", fromlist=[m_name.capitalize()])
ModelClass = getattr(module, m_name.capitalize())
model = ModelClass(cfg)
p = count_parameters(model)
print(f"{m_name:<10} | {cfg['d_ff']:<12} | {p:>12,}")
except Exception as e:
print(f"{m_name:<10} | Error: {e}")
if __name__ == "__main__":
verify_params()