资源简介
实现了回声状态网络,同时含有一维数据集和测试案例,代码运行在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
相关资源
- 二级考试python试题12套(包括选择题和
- pywin32_python3.6_64位
- python+ selenium教程
- PycURL(Windows7/Win32)Python2.7安装包 P
- 英文原版-Scientific Computing with Python
- 7.图像风格迁移 基于深度学习 pyt
- 基于Python的学生管理系统
- A Byte of Python(简明Python教程)(第
- Python实例174946
- Python 人脸识别
- Python 人事管理系统
- 基于python-flask的个人博客系统
- 计算机视觉应用开发流程
- 去除白色背景得到透明背景png的
- python 调用sftp断点续传文件
- python socket游戏
- 基于Python爬虫爬取天气预报信息
- python函数编程和讲解
- Python开发的个人博客
- 基于python的三层神经网络模型搭建
- Tarcotron2(文本转语音)
- python实现自动操作windows应用
- python人脸识别(opencv)
- python 绘图(方形、线条、圆形)
- python疫情卡UN管控
- python 连连看小游戏源码
- 基于PyQt5的视频播放器设计
- KNN算法实战
- 一个简单的python爬虫
- csv文件行列转换python实现代码
评论
共有 条评论