Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. esn = ESN(n_inputs = 1,
  2. n_outputs = 1,
  3. n_reservoir = 500,
  4. sparsity=0.2,
  5. random_state=23,
  6. spectral_radius=1.2,
  7. noise = 0.005)
  8.  
  9. trainlen = 1500
  10.  
  11. validation_set = []
  12. for i in range(0,100):
  13. pred_training = esn.fit(np.ones(trainlen),amazon[i:trainlen+i])
  14. prediction = esn.predict(np.ones(2))
  15. validation_set.append(prediction[0])
  16.  
  17. def MSE(prediction, actual):
  18. return np.mean(np.power(np.subtract(np.array(prediction),actual),2))
  19.  
  20. def run_echo(sr, n, window):
  21. esn = ESN(n_inputs = 1,
  22. n_outputs = 1,
  23. n_reservoir = 500,
  24. sparsity=0.2,
  25. random_state=23,
  26. spectral_radius=sr,
  27. noise = n)
  28.  
  29. trainlen = 1500
  30. current_set = []
  31. for i in range(0,100):
  32. pred_training = esn.fit(np.ones(trainlen),amazon[i:trainlen+i])
  33. prediction = esn.predict(np.ones(window))
  34. current_set.append(prediction[0])
  35. current_set = np.reshape(np.array(current_set),(-1,100))
  36. mse = MSE(current_set, amazon[trainlen:trainlen+100])
  37.  
  38. return (mse, current_set)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement