def scalar_weight_updates(xc, ec, kp, kd):
tx_last = 0
te_last = 0
x_last = 0
e_last = 0
n_samples = xc.shape[0]
dw = np.zeros(n_samples)
r = kd/float(kp+kd)
for t in xrange(n_samples):
t_last = max(tx_last, te_last)
if xc[t]:
dw[t] = x_last*e_last*r**(2*t_last-tx_last-te_last)*geosum(r**2, t_end=t-t_last+1, t_start=1)
x_last = x_last * r**(t-tx_last) + xc[t]
tx_last = t
if ec[t]:
dw[t] = x_last*e_last*r**(2*t_last-tx_last-te_last)*geosum(r**2, t_end=t-t_last+1, t_start=1) # THing...
e_last = e_last * r**(t-te_last) + ec[t]
te_last = t
return np.cumsum(dw)/kd**2
评论列表
文章目录