资源简介
实现了回声状态网络,同时含有一维数据集和测试案例,代码运行在jupyter notebook python3 环境下
代码片段和文件信息
“““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
相关资源
- Shapely-1.6.4.post1-cp36-cp36m-win_amd64.whl
- python 战棋游戏六边形地图代码实现
- naive bayes代码实现(python版)
- springcloudpython
- MODIS_Mosaic.py
- QtDesigner模式识别系统范例——自行车
- 完整工程案例:图像描述---Show and T
- 经典动量与反转交易策略python版
- Python习题集含答案
- Python实现一个简单的3层BP神经网络
- python-urx-master.zip
- Python3.x+Pyqt5实现绘图界面matplotlib绘图
- python-克里金插值 代码
- python就业班.txt
- 爬虫源码:分页爬取,mysql数据库连接
- python 邻接矩阵三种方法实现有向图、
- Python3入门与进阶
- mmdetection在windows中可运行的train.py
- 编译原理由正则表达式到NFA到DFA到最
- Pyboard利用两个Zigbee模块发送并接收
- python实现贪吃蛇小游戏
- Python-TensorFlow语义分割组件
- numpy-1.17.2+mkl-cp37-cp37m-win_amd64.rar
- python大作业--爬虫完美应付大作业.z
- pyltp python3.7可用版本,已编译好的.
- python小游戏大全——30个
- python3网络爬虫开发实战 无密码
- 山东大学抢课脚本
- Python赶集网北京地区招聘信息爬虫
- wordcloud-1.6.0-cp38-cp38-win32.whl
评论
共有 条评论