pre/post: [T, batch, n]; returns weight history [T, npre, npost].
(conn, pre, post, rewards)
| 103 | |
| 104 | |
| 105 | def _drive(conn, pre, post, rewards): |
| 106 | """pre/post: [T, batch, n]; returns weight history [T, npre, npost].""" |
| 107 | T, batch = pre.shape[0], pre.shape[1] |
| 108 | w_hist, pplus_hist, elig_hist = [], [], [] |
| 109 | for t in range(T): |
| 110 | conn.source.s = pre[t].bool().view(batch, -1) |
| 111 | conn.target.s = post[t].bool().view(batch, -1) |
| 112 | conn.update(reward=rewards[t]) |
| 113 | w_hist.append(conn.w.detach().clone()) |
| 114 | ur = conn.update_rule |
| 115 | pplus_hist.append(ur.p_plus.detach().clone()) |
| 116 | elig_hist.append(ur.eligibility.detach().clone()) |
| 117 | return torch.stack(w_hist), torch.stack(pplus_hist), torch.stack(elig_hist) |
| 118 | |
| 119 | |
| 120 | class TestMSTDPFlorian: |
no test coverage detected