MCPcopy Create free account
hub / github.com/BindsNET/bindsnet / _drive

Function _drive

test/network/test_mstdp_florian.py:105–117  ·  view source on GitHub ↗

pre/post: [T, batch, n]; returns weight history [T, npre, npost].

(conn, pre, post, rewards)

Source from the content-addressed store, hash-verified

103
104
105def _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
120class TestMSTDPFlorian:

Calls 2

cloneMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected