Comments (4)
Hello,
Could you try to import reservoirpy from within the 'if name == "main":' statement ?
PS: Thank you for using reservoirpy, we are glad you like it :)
from reservoirpy.
Thank you for the quick reply:)
Yes, I tried adding it into an 'if name == "main":' statement but still getting this RuntimeError. However, what is very odd that actually the code does not stop at the error. Now I added some additional code after this error is printed in the terminal and that runs. Do you have an idea what's happenning? Sorry, I am new to Python, so I might miss something basic.
Pleas the script below that I use:
def split_timeserie_for_task1(forecast, train_length=20000):
X_train, y_train = X[:train_length], X[forecast: train_length+forecast]
X_test, y_test = X[train_length: -forecast], X[train_length+forecast:]
return (X_train, y_train), (X_test, y_test)
def reset_esn():
Win = mat_gen.generate_input_weights(units, 1, input_scaling=input_scaling,
proba=input_connectivity, input_bias=True,
seed=seed)
W = mat_gen.generate_internal_weights(units, sr=spectral_radius,
proba=density, seed=seed)
reservoir = ESN(leak_rate, W, Win, ridge=regularization)
return reservoir
def r2_score(y_true, y_pred):
return 1 - (np.sum((y_true - y_pred)**2) / np.sum((y_true - y_true.mean())**2))
def nrmse(y_true, y_pred):
return np.sqrt((np.sum(y_true - y_pred)**2) / len(y_true)) / (y_true.max() - y_true.min())
if name == 'main':
import numpy as np
import matplotlib.pyplot as plt
from reservoirpy import mat_gen, ESN
from reservoirpy.datasets import mackey_glass
# Generate data
timesteps = 25000
tau = 17
X = mackey_glass(timesteps, tau=tau)
# rescale between -1 and 1
X = 2 * (X - X.min()) / (X.max() - X.min()) - 1
forecast = 10
(X_train, y_train), (X_test, y_test) = split_timeserie_for_task1(forecast)
sample = 500
figsizex = 15
figsizey = 3
# %% ESN training and prediction
units = 100
leak_rate = 0.3
spectral_radius = 1.25
input_scaling = 1.0
density = 0.1
input_connectivity = 0.2
regularization = 1e-8
seed = 1234
Win = mat_gen.generate_input_weights(units, 1, input_scaling=input_scaling,
proba=input_connectivity, input_bias=True,
seed=seed)
W = mat_gen.generate_internal_weights(units, sr=spectral_radius,
proba=density, seed=seed)
reservoir = ESN(leak_rate, W, Win, ridge=regularization)
states = reservoir.train([X_train.reshape(-1, 1)], [y_train.reshape(-1, 1)],
return_states=True, verbose=True) # workers=1
y_pred, states1 = reservoir.run([X_test.reshape(-1, 1)], return_states=True,
verbose=True) # init_state=states[0][-1] workers=1
y_pred = y_pred[0].reshape(-1, 1)
states1 = states1[0]
fig = plt.figure(figsize=(figsizex, figsizey)) # figsize=(15, 7)
plt.plot(np.arange(sample), y_pred[:sample], lw=3, label="ESN prediction")
plt.plot(np.arange(sample), y_test[:sample], linestyle="--", lw=2, label="True value")
plt.plot(np.abs(y_test[:sample] - y_pred[:sample]), label="Absolute deviation")
plt.legend()
plt.show()
from reservoirpy.
Hello,
We have partially fixed the issue, but I am affraid it is caused by the behaviour of Mac OS regarding how to instanciate processes.
Using the if __name__ == "__main__":
statement is mandatory in your case when launching your code (it is actually a good practice in Python in any case). Thank you for drawing this to our attention, we will try to document this error the best we can. In the meantime, next releases v0.2.4-post1 and v0.3.0b1 will avoid raising this error all the time, even when parallelization is deactivated. You can deactivate it by using "sequential" as a backend in the trainnig functions, or by setting it globaly using the set_joblib_backend("sequential")
function.
from reservoirpy.
Thanks a lot for trying to fix this and the help with the workaround. Feel free to let me know if I can be helpful in any testing.
from reservoirpy.
Related Issues (20)
- Potential Error in Documentation HOT 1
- Segfault in classification notebook HOT 5
- Save/Load to/from disk HOT 2
- No warning is triggered when non-existing variable name is used
- Autograd - Feature Request HOT 1
- Mmap error with local parallelization with optuna from the tutorial HOT 1
- datasets.narma doesn't return input series HOT 5
- ValueError: Missing input data for node Reservoir-0.
- Fitting a model on non-temporal data HOT 1
- Feature Importance HOT 4
- Small-world reservoir matrices
- Rank list of degree of influence of input variables HOT 1
- I trying to forecast using reservoirpy HOT 1
- how to save and load a prediction model HOT 2
- Is the long term forecasting example opertion explanation correct HOT 3
- Understand and optimize ESN hyperparameters errors HOT 3
- cant do long term forecasting on yahoo stock market data HOT 4
- Creating a reservoir of custom nodes HOT 2
- LMS doesn't work for single node readout HOT 1
- ESN Parameter Effects HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reservoirpy.