資源簡介
實現(xiàn)了回聲狀態(tài)網(wǎng)絡(luò),同時含有一維數(shù)據(jù)集和測試案例,代碼運行在jupyter notebook python3 環(huán)境下

代碼片段和文件信息
“““This?example?file?shows?how?to?use?the?SimpleESN?class?in?the?scikit-learn
fashion.?It?is?inspired?by?the?minimalistic?ESN?example?of?Mantas?Luko?evi?ius
“““
#?Copyright?(C)?2015?Sylvain?Chevallier?
#?This?program?is?free?software:?you?can?redistribute?it?and/or?modify
#?it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
#?the?Free?Software?Foundation?either?version?3?of?the?License?or
#?(at?your?option)?any?later?version.
#?This?program?is?distributed?in?the?hope?that?it?will?be?useful
#?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
#?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
#?GNU?General?Public?License?for?more?details.
#?You?should?have?received?a?copy?of?the?GNU?General?Public?License
#?along?with?this?program.??If?not?see? .
from?simple_esn?import?SimpleESN
from?sklearn.linear_model?import?Ridge
from?sklearn.grid_search?import?GridSearchCV
from?sklearn.pipeline?import?Pipeline
from?sklearn.metrics?import?mean_squared_error
from?numpy?import?loadtxt?atleast_2d
import?matplotlib.pyplot?as?plt
from?pprint?import?pprint
from?time?import?time
import?numpy?as?np
if?__name__?==?‘__main__‘:
????X?=?loadtxt(‘MackeyGlass_t17.txt‘)
????X?=?atleast_2d(X).T
????train_length?=?2000
????test_length?=?2000
????
????X_train?=?X[:train_length]
????y_train?=?X[1:train_length+1]
????X_test?=?X[train_length:train_length+test_length]
????y_test?=?X[train_length+1:train_length+test_length+1]
????#?Simple?training
????my_esn?=?SimpleESN(n_readout=1000?n_components=1000
???????????????????????damping?=?0.3?weight_scaling?=?1.25)
????echo_train?=?my_esn.fit_transform(X_train)
????regr?=?Ridge(alpha?=?0.01)
????regr.fit(echo_train?y_train)
????echo_test?=?my_esn.transform(X_test)
????y_true?y_pred?=?y_test?regr.predict(echo_test)
????err?=?mean_squared_error(y_true?y_pred)
????
????fp?=?plt.figure(figsize=(12?4))
????trainplot?=?fp.add_subplot(1?3?1)
????trainplot.plot(X_train[100:600]?‘b‘)
????trainplot.set_title(‘Some?training?signal‘)
????echoplot?=?fp.add_subplot(1?3?2)
????echoplot.plot(echo_train[100:600:20])
????echoplot.set_title(‘Some?reservoir?activation‘)
????testplot?=??fp.add_subplot(1?3?3)
????testplot.plot(X_test[-500:]?‘b‘?label=‘test?signal‘)
????testplot.plot(y_pred[-500:]?‘g‘?label=‘prediction‘)
????testplot.set_title(‘Prediction?(MSE?%0.3f)‘?%?err)
????testplot.legend(loc=‘lower?right‘)
????plt.tight_layout(0.5)
????#?Grid?search
????pipeline?=?Pipeline([(‘esn‘?SimpleESN(n_readout=1000))
?????????????????????????(‘ridge‘?Ridge(alpha?=?0.01))])
????parameters?=?{
????????‘esn__n_readout‘:?[1000]
????????‘esn__n_components‘:?[1000]
????????‘esn__weight_scaling‘:?[0.9?1.25]
????????‘esn__damping‘:?[0.3]
????????‘ridge__alpha‘:?[0.01?0.001]
????}
????grid_search?=?GridSearchCV(pipeline?parameters?n_jobs=-1?verbose=1?cv=3)
????print?(“Starting?grid?search?with?parameters“)
????pprint?(parameter
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-06-26?18:47??ESN\
?????目錄???????????0??2018-06-26?18:47??ESN\.ipynb_checkpoints\
?????目錄???????????0??2018-06-26?20:41??ESN\simple_esn\
?????文件?????????129??2017-05-23?14:34??ESN\simple_esn\.codeclimate.yml
?????文件?????????371??2017-05-23?14:34??ESN\simple_esn\.coveragerc
?????目錄???????????0??2018-06-26?19:20??ESN\simple_esn\.ipynb_checkpoints\
?????文件??????360202??2018-06-26?19:01??ESN\simple_esn\.ipynb_checkpoints\plot_mackey_glass-checkpoint.ipynb
?????文件???????10181??2018-06-26?19:00??ESN\simple_esn\.ipynb_checkpoints\simple_esn-checkpoint.ipynb
?????文件????????5929??2018-06-26?20:41??ESN\simple_esn\.ipynb_checkpoints\test-checkpoint.ipynb
?????文件?????????987??2017-05-23?14:34??ESN\simple_esn\.travis.yml
?????文件???????35142??2017-05-23?14:34??ESN\simple_esn\LICENSE
?????文件??????265429??2017-05-23?14:34??ESN\simple_esn\MackeyGlass_t17.txt
?????文件????????6598??2018-06-26?19:05??ESN\simple_esn\plot_mackey_glass.ipynb
?????文件????????3965??2017-05-23?14:34??ESN\simple_esn\plot_mackey_glass.py
?????文件????????2072??2017-05-23?14:34??ESN\simple_esn\README.md
?????文件??????????30??2017-05-23?14:34??ESN\simple_esn\requirements.txt
?????文件???????10181??2018-06-26?19:00??ESN\simple_esn\simple_esn.ipynb
?????文件????????7922??2017-05-23?14:34??ESN\simple_esn\simple_esn.py
?????文件????????5929??2018-06-26?20:41??ESN\simple_esn\test.ipynb
?????文件????????1751??2017-05-23?14:34??ESN\simple_esn\test_simple_esn.py
?????目錄???????????0??2018-06-26?19:00??ESN\simple_esn\__pycache__\
?????文件????????6290??2018-06-26?19:00??ESN\simple_esn\__pycache__\simple_esn.cpython-36.pyc
評論
共有 條評論