关于极限学习机,原理较为简单,但也饱受争议。这篇文章只列举几个应用,关于极限学习机的相关文章,请参考如下链接:

Extreme learning machine (ELM) 到底怎么样,有没有做的前途? - 知乎

Extreme learning machine (ELM) 到底怎么样,有没有做的前途?

深度学习(deep learning)和极限学习机(extreme learning machine)的区别和联系之处? - 知乎

深度学习(deep learning)和极限学习机(extreme learning machine)的区别和联系之处?

贴个大佬的图,图片来自Extreme learning machine (ELM) 到底怎么样,有没有做的前途? - 邓博元的回答 - 知乎 Extreme learning machine (ELM) 到底怎么样,有没有做的前途? - 知乎

咳咳,下面进入正题

第一个例子,构建一个具有极限学习机规则的深度信念网络,关于深度信念网络现在已经很少用了,有很多原因,现在的算力已经不再需要这么折腾了,而且逐层预训练会有副作用。具有极限学习机规则的深度信念网络,即把DBN的每一层的特征提取过程使用ELM机制代替,看个图就懂了。

相关的理论推导可参考如下3篇文献:

[1]Deep Supervised Learning Approach for Condition-Based Maintenance of Naval Propulsion Systems

[2]Aircraft Eng%ines Remaining Useful Life Prediction with an Adaptive Denoising Online Sequential Extreme Learning Machine.

[3]Aircraft Engines Remaining Useful Life Prediction with an Improved Online Sequential Extreme Learning Machine.

首先导入一个发动机剩余使用寿命数据集

load('big_data');

看下数据结构

将数据划分为训练集和测试集

trainRatio=0.4; %学习率

testRatio=1-trainRatio;

Q=size(Outputs,1);

[trainInd,~,testInd] = divideint(Q,trainRatio,0,testRatio);

Trinputs=S(Inputs(trainInd,:),0,1); % 训练输入

Tsinputs=S(Inputs(testInd,:),0,1); % 训练目标

Trtargets=Outputs(trainInd,:); % 测试输入

Tstargets=Outputs(testInd,:); % 测试目标

clearvars -except Trinputs Tsinputs Trtargets Tstargets testInd trainInd

下面定义DBN参数

Options.activF ='radbas' ; % 激活函数

Options.net_Architecture=[100 100 254]; % 深度网络的网络架构(每个隐层中的一系列神经元)

Options.mini_batch=5;

开始训练

[net] = DBN_OSELM(Trinputs,Tsinputs,Trtargets,Tstargets,Options)% DBN

作图

plot(testInd,Tstargets,'.',testInd,net.yts_hat,'+')

legend('Desired ','Predicted ')

再看一个基于自编码器的极限学习机的图像降噪的小例子,首先看下结构

基于自编码器的极限学习机图像降噪

然后看下训练集

进行训练集和测试集的构建

pathname = uigetdir;

allfiles = dir(fullfile(pathname,'*.jpg'));

xtr=[]; % 初始化训练输入

gamma=[96 97];% 每个图像的尺寸

for i=1:size(allfiles,1)

x=imread([pathname '\\' allfiles(i).name]);

x=imresize(x,gamma);

x=rgb2gray(x);

x=double(x);

xtr=[xtr; x];% 训练集构建

end

% 导入测试数据

pathname = uigetdir;

allfiles = dir(fullfile(pathname,'*.jpg'));

xts=[]; % initialize testing inputs

for i=1:size(allfiles,1)

x=imread([pathname '\\' allfiles(i).name]);

x=imresize(x,gamma);

x=rgb2gray(x);

x=double(x);

xts=[xts; x];% 测试集构建

end

进行算法参数初始化

NumberofHiddenNeurons=500; % 隐层神经元数量

D_ratio=0.35; % 每个选定帧中的信噪比

DB=1; % 高斯白噪声功率

ActivationFunction='sig'; % 激活函数

frame=20; % 每帧的尺寸

下面进行训练和测试, 在训练过程中,随机添加高斯白噪声

[AE_net]=elm_AE(xtr,xts,NumberofHiddenNeurons,ActivationFunction,D_ratio,DB,frame)

训练完成后,将不再需要使用InputWeight将输入映射到隐层。最后看下结果

subplot(121)

corrupted=AE_net.x(:,1:gamma(2)*2);

imshow(corrupted')

title('corrupted images ');

subplot(122)

regenerated=AE_net.Ytr_hat(:,1:gamma(2)*2);

imagesc(regenerated'), colormap('gray');

title('regenerated images');

可参考如下参考文献

[1] P. Vincent, H. Larochelle, I. Lajoie, Y. Bengio, and P.-A. Manzagol, “Stacked Denoising Autoencoders: Learning Useful Representations in a Deep Network with a Local Denoising Criterion,” J. Mach. Learn. Res., vol. 11, no. 3, pp. 3371–3408, 2010.

[2] L. le Cao, W. bing Huang, and F. chun Sun, “Building feature space of extreme learning machine with sparse denoising stacked-autoencoder,” Neurocomputing, vol. 174, pp. 60–71, 2016.

[3] G. Bin Huang, “What are Extreme Learning Machines? Filling the Gap Between Frank Rosenblatt’s Dream and John von Neumann’s Puzzle,” Cognit. Comput., vol. 7, no. 3, pp. 263–278, 2015.

下面再看一个很简单的使用极限学习机建议回归模型的问题

首先生成模拟训练数据

a=0;

b=1;

x1 = a + (b-a).*rand([500 1]);

x2 = a + (b-a).*rand([500 1]);

x=[x1 x2];

y = (1.3356 .* (1.5 .* (1 - x1)) + (exp(2 .* x1 - 1) .* sin(3 .* pi .* (x1 - 0.6).^2))+ (exp(3 .* (x2 - 0.5)) .* sin(4 .* pi .* (x2 - 0.9).^ 2)));

划分训练集和测试集

Ns=floor(0.8*length(y)); % 前80%的数据用于训练

xtrain=x(1:Ns,:); %训练数据

ytrain=y(1:Ns);

xtest=x(Ns+1:end,:); % 测试数据

ytest=y(Ns+1:end);

[xtrain,mux,sigmax] = zscore(xtrain); % 归一化

[ytrain,muy,sigmay] = zscore(ytrain);

Neurons_HL=35; %隐层神经元数量

Input_Features=size(xtrain,2);

Inputweights=rand(Neurons_HL,Input_Features)*2-1; % 随机生成输入权重

Bias_HL=rand(Neurons_HL,1);Biasmatrix=Bias_HL(:,ones(1,Ns)); % 随机生成偏执、、偏置

Prod=xtrain*Inputweights';

H=Prod+Biasmatrix'; % 隐藏层输出

选择激活函数并进行训练

AF='tanh'; % 选择激活函数

if strcmp(AF,'tanh')

Hout=tanh(H);

elseif strcmp(AF,'sig')

Hout=1./(1+exp(-H));

elseif strcmp(AF,'sin')

Hout=sin(H);

elseif strcmp(AF,'cos')

Hout=cos(H);

elseif strcmp(AF,'RBF')

Hout=radbas(H);

elseif strcmp(AF,'tf')

Hout=tribas(H);

end

type='OT';

if strcmp(type,'MP')

Hinv=pinv(Hout);

elseif strcmp(type,'RCOD')

Hinv=RCOD(Hout);

elseif strcmp(type,'OT')

lambda=10000;

Hinv=ORT(Hout,lambda);

end

Outputweights=(Hinv)*ytrain;

ModelOutputs=Hout*Outputweights; % 在训练数据集上预测的ELM的输出

最后进行模型测试并作图

xnew=(xtest-mux)./sigmax; % 测试数据标准化

Prod=Inputweights*xnew';

H=Prod+Bias_HL(:,ones(1,size(xnew,1)));

if strcmp(AF,'tanh') % 选择激活函数

Hout=tanh(H);

elseif strcmp(AF,'sig')

Hout=1./(1+exp(-H));

elseif strcmp(AF,'sin')

Hout=sin(H);

elseif strcmp(AF,'cos')

Hout=cos(H);

elseif strcmp(AF,'RBF')

Hout=radbas(H);

elseif strcmp(AF,'tf')

Hout=tribas(H);

end

Ypred=Hout'*Outputweights;

ypred=Ypred*sigmay+muy;

R=corr(ytest,ypred); % 相关系数

fprintf('R= %4.4f \n',R)

RMSE=sqrt(mean((ypred-ytest).^2));

fprintf('RMSE= %4.4f \n',RMSE)

figure

plot(ytest)

hold on

plot(ypred)

legend('Actual data','Predictions')

xlabel('samples')

完整代码见如下链接:

正在为您运送作品详情

公众号:高斯的手稿

推荐链接

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: