Ejemplo n.º 1
0
# inputting
LEAK = 0.9
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss0 = np.mean((ys - ys_target)**2)
print('loss before training', loss0)

# training
LA = 0.01
esn.update(ys_target.reshape(-1, 1), la=LA)

# inputting again
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss1 = np.mean((ys - ys_target)**2)
print('loss after training', loss1)

# plot
plt.plot(ys, label='prediction', color='r', marker='o')
plt.plot(ys_target, label='target', color='k', marker='o')
Ejemplo n.º 2
0
# inputting
LEAK = 0.9
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss0 = np.mean((ys[DELAY:] - ys_target[DELAY:])**2)
print('loss before training', loss0)

# training
LA = 0.01
esn.update(ys_target[DELAY:].reshape(-1, 1), t_start_at=DELAY, la=LA)

# inputting again
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss1 = np.mean((ys[DELAY:] - ys_target[DELAY:])**2)
print('loss after training', loss1)

# plot
plt.plot(ys[DELAY:], label='prediction', color='r', marker='o')
plt.plot(ys_target[DELAY:], label='target', color='k', marker='o')
Ejemplo n.º 3
0
# inputting
LEAK = 0.9
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss0 = np.mean((ys[BIT - 1:] - ys_target[BIT - 1:])**2)
print('loss before training', loss0)

# training
LA = 0.01
esn.update(ys_target[BIT - 1:].reshape(-1, 1), t_start_at=BIT - 1, la=LA)

# inputting again
ys = []
for u in us:
    y = esn(u.reshape(1, 1), leak=LEAK)
    ys.append(y[0][0])

# compute loss
ys = np.asarray(ys)
loss1 = np.mean((ys[BIT - 1:] - ys_target[BIT - 1:])**2)
print('loss after training', loss1)

# plot
plt.plot(ys[BIT - 1:], label='prediction', color='r', marker='o')
plt.plot(ys_target[BIT - 1:], label='target', color='k', marker='o')