summaryrefslogtreecommitdiff
path: root/experiments
diff options
context:
space:
mode:
authorYurenHao0426 <Blackhao0426@gmail.com>2026-04-02 21:14:25 -0500
committerYurenHao0426 <Blackhao0426@gmail.com>2026-04-02 21:14:25 -0500
commit045385c975e7f6b64678edf8835e771614352f9f (patch)
treedb3fffe13ea4215e285de943e06d7331d10e8d40 /experiments
parent1a917bca503c3a53610f363929f24e44a77fcb48 (diff)
Fix ep_synthetic: bp dict needs L+1 entries for EP credit comparison
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'experiments')
-rw-r--r--experiments/ep_synthetic.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/experiments/ep_synthetic.py b/experiments/ep_synthetic.py
index bb7f4af..7daecde 100644
--- a/experiments/ep_synthetic.py
+++ b/experiments/ep_synthetic.py
@@ -95,7 +95,7 @@ def compute_diagnostics(model, teacher, dev, d, C, L, beta=0.5, T_nudge=20, alph
hs=[x.detach().requires_grad_(True)]
for b in model.blocks:hs.append(hs[-1]+b(hs[-1]))
lo=model.out_head(hs[-1]);loss=F.cross_entropy(lo,y)
- gs=torch.autograd.grad(loss,hs);bp={l:gs[l].detach() for l in range(L)}
+ gs=torch.autograd.grad(loss,hs);bp={l:gs[l].detach() for l in range(L+1)}
# EP credit
with torch.no_grad():_,hf=model(x,return_hidden=True)
h_free=[h.detach().clone() for h in hf]