Code and stored results for the IEEE Communications Letters submission

Semantic Multiplexing Gain in Wireless Systems via Expanded Embeddings:
A BERT Case Study. Includes the shared library, all experiment scripts
(training with and without SNR-aware MAML, the token-domain comparison,
the K sweep, and DistilBERT), the replot script that regenerates every
figure from the stored results, the supplementary probe-versus-cosine
analysis, and the raw results behind every figure in the letter.
This commit is contained in:
Ki-Ho Lee
2026-08-26 22:02:59 +09:00
commit 248e637f55
21 changed files with 8269 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
# cl_todma_load.py — ToDMA load sweep (evaluation only, no training).
#
# Evaluates the ToDMA token-domain scheme (T=24, L=128, genie-aided
# association) for U in {1,2,3,5,6} on the held-out test set, matching
# the U=4 run stored in cl_results.json, so that Fig. 3 can show the
# ToDMA aggregate fidelity across load.
import argparse, os, json
import torch
from cl_experiments import (
load_agnews_labeled, Extractor, SplitCache, todma_eval, EVAL_SNRS
)
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--save-dir", default="fig_cl")
ap.add_argument("--frames", type=int, default=200)
args = ap.parse_args()
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
os.makedirs(args.save_dir, exist_ok=True)
print(f"[Device: {device}]", flush=True)
train_items, test_items = load_agnews_labeled()
bert = Extractor("bert-base-uncased", device)
cache = SplitCache(bert, train_items, test_items)
R = {}
for U in [1, 2, 3, 5, 6]:
print(f"\n=== ToDMA U={U} (T=24, L=128) ===", flush=True)
res, _ = todma_eval(bert, cache, device, U=U, T=24, L=128,
n_frames=args.frames)
key = f"todma_U{U}_T24_L128"
R[key] = {str(s): res[s] for s in EVAL_SNRS}
with open(os.path.join(args.save_dir,
"cl_results_todma_u.json"), "w") as f:
json.dump(R, f, indent=1)
print("\nToDMA load sweep complete.", flush=True)
if __name__ == "__main__":
main()