当前位置: 首页 > news >正文

FORCE learning

参考文献

  • Generating Coherent Patterns of Activity from Chaotic Neural Networks
    在这里插入图片描述

  • Collective dynamics of rate neurons for supervised learning in a reservoir computing system在这里插入图片描述

工作原理

在这里插入图片描述
将递归最小二乘法(RLS)用于储备池的输出权重在线更新

import numpy as np
import random
import os
import time
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib qt5
from tqdm.notebook import tqdm

def set_seed(seed=None):
    pass
    
system_name = 'lorentz'
Y = np.loadtxt('dataset/'+system_name+'.txt', delimiter=',').T
T = Y.shape[1]

inSize = Y.shape[0]
outSize = inSize 
resSize = 400 
a = 0.9
K = 1
reg = 1e-6
input_scaling = 0.5

train_time = 1000
seed = 44  
set_seed(seed)
Win = (np.random.rand(resSize,1+inSize)-0.5) * input_scaling
W = np.random.rand(resSize,resSize)-0.5
rhoW = np.sqrt(max(abs(np.linalg.eig(W@W.T)[0]))) # maximal eigenvalue
W = W/rhoW*(K-1+a)/a 
Wout = np.random.rand(outSize, 1+inSize+resSize) - 0.5


x = np.zeros((resSize,1))
S = np.zeros((1+inSize+resSize,T))
Z = np.zeros([outSize, T])
Error = np.zeros([inSize, T])
Time = list(range(T))
P = np.eye(S.shape[0])/reg

f, ax =plt.subplots(nrows=1,ncols=2, figsize=(20,5))
ax[0].set_xlabel('Time')
ax[0].set_ylabel('f(t)')
line1, line2, line3 = None, None, None
plt.grid(True)
plt.ion()

for t in tqdm(range(1,T)):
    if t < train_time:
        u = Y[:,t-1:t] + np.random.randn(inSize,1)*0.001
    else:
        u = z
    x = (1-a) * x + a * np.tanh(Win @ np.vstack((1, u))) + W @ x)
    s =  np.vstack((1,u,x))
    z = Wout @ s
    y = Y[:,t:t+1]
    dy = z - y
    P -= P @ s @ s.T @ P/(1+s.T @ P @ s)
    dWout = dy @ (P @ s).T    
    
    if t < train_time:
        Wout -= dWout
    
    S[:,t:t+1] = s
    Z[:,t:t+1] = z
    Error[:,t:t+1] = np.abs(dy)
    
    """
    画图
	"""
    if line1 is None:
        line1 = ax[0].plot(Time[1:t],Z[0,1:t],'-g',marker='*', label='output')[0]
        line2 = ax[0].plot(Time[1:t],Y[0,1:t],'-r',marker='*', label='target')[0]
        line3 = ax[1].plot(Time[1:t],Error[0,1:t],'-k',marker='.', label='error')[0]
        ax[0].legend(loc='upper left')
        ax[1].legend(loc='upper left')
    
    line1.set_xdata(Time[1:t])
    line1.set_ydata(Z[0,1:t])
    line3.set_xdata(Time[1:t])
    line3.set_ydata(Error[0,1:t])
    line2.set_xdata(Time[1:t])
    line2.set_ydata(Y[0,1:t])
    
    ax[0].set_xlim([t-300,t+1])
    ax[0].set_ylim([0,1])
    ax[1].set_xlim([t-300,t+1])
    ax[1].set_yscale("log")
    ax[1].set_ylim([1e-6,10])
    plt.pause(0.001)
  • 训练阶段: t < train_time = 1000 t < \text{train\_time} = 1000 t<train_time=1000
    在这里插入图片描述
  • 训练结束后运行, t > train_time = 1000 t > \text{train\_time} = 1000 t>train_time=1000

在这里插入图片描述
在这里插入图片描述

相关文章:

  • 小黑学前端日记——第1天
  • 小黑学前端日记——第2天
  • Windows Workflow Beta2 HOL学习笔记系列教程
  • 松弛法求解给定边界条件的泊松方程
  • Implicit Graph Neural Networks
  • DB2 简史
  • 部分 SCI 英文期刊缩写对照表
  • matlab 计算 Lorenz 系统最大李雅普诺夫指数
  • Data-Driven Science and Engineering —— Machine Learning, Dynamical Systems, and Control
  • DB2 命令行处理器(CLP)中的常用命令
  • 随机奇异值分解(Randomized SVD, rSVD)
  • 绘制 Logistic 映射分叉图
  • 利用SQL Server 2000 技能来学习 DB2 V8
  • Debian 配置Bind9 DNS服务器
  • 动态模式分解(DMD)
  • Android路由框架AnnoRouter:使用Java接口来定义路由跳转
  • C++类中的特殊成员函数
  • Flannel解读
  • iOS 颜色设置看我就够了
  • linux学习笔记
  • Mac转Windows的拯救指南
  • oschina
  • Python_OOP
  • Python学习之路13-记分
  • Rancher如何对接Ceph-RBD块存储
  • session共享问题解决方案
  • 阿里中间件开源组件:Sentinel 0.2.0正式发布
  • 从零开始学习部署
  • 计算机在识别图像时“看到”了什么?
  • 讲清楚之javascript作用域
  • 开源地图数据可视化库——mapnik
  • 普通函数和构造函数的区别
  • 嵌入式文件系统
  • 如何胜任知名企业的商业数据分析师?
  • 突破自己的技术思维
  • ​LeetCode解法汇总2808. 使循环数组所有元素相等的最少秒数
  • ​软考-高级-系统架构设计师教程(清华第2版)【第12章 信息系统架构设计理论与实践(P420~465)-思维导图】​
  • (1/2) 为了理解 UWP 的启动流程,我从零开始创建了一个 UWP 程序
  • (AtCoder Beginner Contest 340) -- F - S = 1 -- 题解
  • (LeetCode 49)Anagrams
  • (附源码)python旅游推荐系统 毕业设计 250623
  • (附源码)spring boot火车票售卖系统 毕业设计 211004
  • (附源码)springboot太原学院贫困生申请管理系统 毕业设计 101517
  • (黑马出品_高级篇_01)SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式
  • (转)C#调用WebService 基础
  • .net core 控制台应用程序读取配置文件app.config
  • .NET/C# 使用 SpanT 为字符串处理提升性能
  • .net解析传过来的xml_DOM4J解析XML文件
  • .Net转前端开发-启航篇,如何定制博客园主题
  • @private @protected @public
  • [ C++ ] template 模板进阶 (特化,分离编译)
  • [ 代码审计篇 ] 代码审计案例详解(一) SQL注入代码审计案例
  • [\u4e00-\u9fa5] //匹配中文字符
  • [100天算法】-实现 strStr()(day 52)
  • [1525]字符统计2 (哈希)SDUT