Rename simulation scripts to descriptive names

This commit is contained in:
Ki-Ho Lee
2026-08-25 20:26:08 +09:00
parent 1fc9cad834
commit d9f6f4ac53
10 changed files with 8 additions and 8 deletions
+20
View File
@@ -0,0 +1,20 @@
import types, numpy as np, torch
import maml_semantic as M
torch.manual_seed(0)
def cfg(**k):
b=dict(d=64,U=4,H=4,tau=0.45,lam=0.1,snr_min=0.0,snr_max=20.0,snr_step=2.0,
inner_lr=0.01,inner_steps=5,outer_lr=1e-3,meta_epochs=70,joint_epochs=70,
batch=64,n_mc=60,seed=42,scenario='HIGH',decoder_only=True); b.update(k)
return types.SimpleNamespace(**b)
def run(d):
c=cfg(d=d); dev='cpu'; rng=np.random.default_rng(42); scen=M.SCENARIO_CONFIGS['HIGH']
m=M.SemanticCommSystem(c.d,c.U,c.H,decoder_only=True).to(dev)
M.MAMLTrainer(m,c,dev,rng,scen).train()
res=M.evaluate_model(m,c,dev,rng,'rayleigh',scen)
snr=np.arange(0,20.0001,2); i=int(np.argmin(np.abs(snr-10)))
rho=res['rho'][i]; mask=~np.eye(c.U,dtype=bool)
return res['ser'][i],res['cos'][i],float(np.abs(rho[mask]).mean())
print("=== d sweep (HIGH, SNR=10dB) ===")
for d in [32,64,128]:
s,co,r=run(d); print(f"d={d:3d}: SER={s:.3f} cos={co:.3f} |rho_off|={r:.3f}")
print("DONE")