Restructure package: descriptive study documentation and clean layout

This commit is contained in:
Ki-Ho Lee
2026-08-25 20:25:46 +09:00
parent 7e831474af
commit 1fc9cad834
38 changed files with 397 additions and 2262 deletions
+31
View File
@@ -0,0 +1,31 @@
"""End-to-end (learnable encoder) vs decoder-only MAML, HIGH scenario.
Verifies Reviewer-1 Comment-3 claim that cross-attention stays stable and
effective when the encoder is also learned."""
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=120, joint_epochs=120, batch=64, n_mc=80, seed=42,
scenario='HIGH', decoder_only=True)
b.update(k); return types.SimpleNamespace(**b)
def run(decoder_only):
c = cfg(decoder_only=decoder_only); dev='cpu'; rng=np.random.default_rng(c.seed)
scen=M.SCENARIO_CONFIGS[c.scenario]
mdl=M.SemanticCommSystem(c.d,c.U,c.H,decoder_only=decoder_only).to(dev)
M.MAMLTrainer(mdl,c,dev,rng,scen).train()
res=M.evaluate_model(mdl,c,dev,rng,"rayleigh",scen)
snr=np.arange(0,20.0001,2);
def at(s): return res['ser'][int(np.argmin(np.abs(snr-s)))], res['cos'][int(np.argmin(np.abs(snr-s)))]
i10=int(np.argmin(np.abs(snr-10))); rho=res['rho'][i10]; mask=~np.eye(c.U,dtype=bool)
return at(4), at(10), at(16), float(np.abs(rho[mask]).mean())
print("=== END-TO-END (learnable encoder) vs DECODER-ONLY, HIGH ===")
for tag, do in [("decoder-only (frozen enc)", True), ("end-to-end (learnable enc)", False)]:
(s4,c4),(s10,c10),(s16,c16),rho = run(do)
print(f" {tag:30s} SER@4/10/16 = {s4:.3f}/{s10:.3f}/{s16:.3f} "
f"cos@10={c10:.3f} |rho_off|@10={rho:.3f}")
print("DONE.")