⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaotic_prediction2.m

📁 This program is prepared as an one-step EEG predictor. this is used a fuzzy neural network which is
💻 M
字号:
clear;clc;close all
%% chaotic signal generation
% A = 4;
% x = zeros(1,1500) + 0.1;
% for k = 1:1499
%     x(k+1) = A * x(k) * (1-x(k));
% end
load emotion_p1
%% train and test sets
% train_set = x(1,1:1200);
%% training the FNN
d=10;
C1 = rand(47,d);
W1 = 0.2*ones(47,d);
f = rand(1,d);
M1 = ones(1,d);
% load gooddata.mat;
C=C1;
W=W1;
% f=f1;
M=M1;
alpha = 0.1;
Error = [];
e = 1;
E = 0;
q = 1;
while e > 0.001
    outputdata = [];
    desireddata = [];
    e = 0;
    e = E;
    for p = 1:60
        a = 0;
        b = 0;
        input = emotion_p1(p,1:47);
        desired_output = emotion_p1(p,48)/3;
        %output computation:
            for j = 1:d
                for i = 1:47
                    M(j) = M(j) * exp ( -((input(i) - C(i,j)) / W(i,j))^2 );
                end
                a = a + f(j) * M(j);
                b = b + M(j);
            end
            y = a / b;
            outputdata = [outputdata y];
            desireddata = [desireddata desired_output];
         %weight correction:   
            for j=1:d
                    f(j) = f(j) - (alpha * ((y - desired_output) / b) * M(j)) ;
                for i=1:47
                    T1 = alpha * ((y - desired_output) / b) * (f(j) - y) * M(j) * (2 * (input(i) - C(i,j))/(W(i,j)).^2);
                    T2 = alpha * ((y - desired_output) / b) * (f(j) - y) * M(j) * (2 * (input(i) - C(i,j).^2)/(W(i,j)).^3);
                    W(i,j) = W(i,j) - T2;
                    C(i,j) = C(i,j) - T1;
                 end
            end
        %Error computation:
            e = e + (1/2)*(y - desired_output)^2;
            M=ones(1,d);
            E = e;
    end
    
    %normalizing error:
    e = sqrt((1/(1200*q))*e.^2);
    q = q + 1
    Error = [Error,e];
end

plot (Error)
figure; plot (outputdata,'r'); hold on; plot (desireddata)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -