Drive a conv/local connection with explicitly-shaped spike trains. pre/post: [T, batch, *node_shape]. Returns (weight_change, [eligibility...]).
(conn, pre, post)
| 245 | |
| 246 | |
| 247 | def _drive_shaped(conn, pre, post): |
| 248 | """Drive a conv/local connection with explicitly-shaped spike trains. |
| 249 | |
| 250 | pre/post: [T, batch, *node_shape]. Returns (weight_change, [eligibility...]). |
| 251 | """ |
| 252 | T = pre.shape[0] |
| 253 | w0 = conn.w.detach().clone() |
| 254 | eligs = [] |
| 255 | for t in range(T): |
| 256 | conn.source.s = pre[t].bool() |
| 257 | conn.target.s = post[t].bool() |
| 258 | conn.update(reward=1.0) |
| 259 | eligs.append(conn.update_rule.eligibility.detach().clone()) |
| 260 | return conn.w.detach() - w0, eligs |
| 261 | |
| 262 | |
| 263 | _LOCAL_CASES = [ |
no test coverage detected