21 lines
995 B
Python
Executable File
21 lines
995 B
Python
Executable File
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")
|