function [net]=DBN_OSELM(In,TsIn,Tar,TsTar,Options)
% DBN-ELM : deep belief network based Online Sequential Extreme Learning Machine
activF=Options.activF; % Activation function
net_Architecture=Options.net_Architecture; % Network Architecture
mini_batch=Options.mini_batch; % minibatch size
% devide into mini-batches
[Trinputs,Trtargets]=devide_blocks(In,Tar,mini_batch);
% Start training
% Initialization phase
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
start_time_train=cputime;
for i=1:length(net_Architecture)
% load initial mini-batches
if i==1
P = Trinputs{1};
else
P=Hn{1}';
end
% generate input weights
input_weights=randn(net_Architecture(i),size(P,2));
% calculating the temporal hidden layer
tempH=input_weights*P';
% Activation function
switch lower(activF)
case {'sig','sigmoid'}
%%%%%%%% Sigmoid
H = 1 ./ (1 + exp(-tempH));
case {'radbas'}
%%%%%%%% Radial basis function
H = radbas(tempH);
case {'hardlim'}
%%%%%%%% hardlim function
H = hardlim(tempH);
case {'hardlims'}
%%%%%%%% hardlims function
H = hardlims(tempH);
case {'sin'}
%%%%%%%% sin function
H = sin(tempH);
case {'relu'}
%%%%%%%% sin function
H = max(tempH,0);
%%%%%% More activation functions can be added here
end
% unsupervised learning
Hn{1}=H; % save the new features representations
B=pinv(H') * P ; % calculate B of the encoder
M= pinv(H * H'); % calculate the covariance matrix
E{1}=P-(H'*B); % calculate reconstruction error
% supervised learning
if i==length(net_Architecture)
T=Trtargets{1}; % load targets
beta=pinv(H') * T ; % determine initial beta
Esup{1}=T-(Hn{1}' * beta); % calculate prediction error
end
% end of initialization phase
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% start sequential Learning
if numel(Trinputs)>1%
for t=2:numel(Trinputs)-1
% load new mini-batches
if i==1
Pnew = Trinputs{t};
else
Pnew =Hn{t}';
end
% temporal hidden layer; We no longer need the old input weighting matrix, we will use pinv (B ') instead.
Hn{t}=pinv(B')*Pnew';
% no need to the use of activation function ; activation beta is already calculated after activation
%% unsupervised learning
E{t}=Pnew-(Hn{t}' * B);
K =(M * Hn{t}) *((eye(size(Pnew,1))+(Hn{t})' * M * Hn{t})^(-1));
M = (M -( K * (Hn{t})' * M));
B = B + M * Hn{t} * (E{t});
%% supervised learning
if i== length(net_Architecture)
Tnew=Trtargets{t};
Esup{t}=Tnew-(Hn{t}' * beta);
beta = beta + M * Hn{t} * (Esup{t});
end
end
end
%save updated beta (unsupervised)
weights{i}=pinv(B');
end
end_time_train=cputime;
Tr_Time=end_time_train-start_time_train;
% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%%%%%% training accuracy
% encoding
input=In;
for i=1:length(net_Architecture)
input=(weights{i}*input')';
end
mapping_TRAIN=input;
ytr_hat= smooth(S(mapping_TRAIN*beta,min(Tar),max(Tar)));% Scaling + removing outliers
trainingAccuracy=sqrt(mse(ytr_hat-Tar));
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
%%%%%% testing accuracy
start_time_test=cputime;
% encoding
input=TsIn;
for i=1:length(net_Architecture)
input=(weights{i}*input')';
end
mapping_TEST=input;
yts_hat= smooth(S(mapping_TEST*beta,min(TsTar),max(TsTar))); % Scaling + removing outliers
Ts_Time=cputime-start_time_test;
testingAccuracy=sqrt(mse(yts_hat-TsTar));
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
% Save results
net.Tr_Time=Tr_Time;
net.Ts_Time=Ts_Time;
net.Tr_acc=trainingAccuracy;
net.Ts_acc=testingAccuracy;
net.ytr_hat=ytr_hat;
net.yts_hat=yts_hat;
end
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1.版本:matlab2022A,包含仿真操作录像和代码注释,操作录像使用windows media player播放。 2.领域:DBN-ELM深度信念网络 3.内容:基于DBN-ELM深度信念网络的在线序贯极限学习机的数据分类仿真。 Tnew=Trtargets{t}; Esup{t}=Tnew-(Hn{t}' * beta); beta = beta + M * Hn{t} * (Esup{t}); 4.注意事项:注意MATLAB左侧当前文件夹路径,必须是程序所在文件夹位置,具体可以参考视频录。
资源推荐
资源详情
资源评论






























收起资源包目录









共 6 条
- 1
资源评论

- lm198554512362024-04-30资源不错,内容挺好的,有一定的使用价值,值得借鉴,感谢分享。


fpga和matlab

- 粉丝: 19w+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 集团信息化规划汇报方案1.docx
- M蛋白的鉴别-2017.pptx
- 人工智能进校园仍需多方努力.docx
- 钢管扣件式脚手架方案.doc
- 边坡支护工程项目责任承包合同.doc
- 保卫消防管理制度.doc
- 精益产品开发体系和Devops.pptx
- 一般职员的人事考绩表格.doc
- FTTH工程监理规划(参考模板).doc
- 广安市广前大道改造(市政土建及园林绿化)工程监理质量评估报告.doc
- 任务十七水箱水位控制系统编程与实现.ppt
- 伊万诺物联网智能路灯节能最佳解决措施.docx
- 校区图书馆工程(招标).doc
- 2018届高三数学一轮复习-第十二章-复数、算法、推理与证明-第四节-直接证明和间接证明-理.ppt
- 预拌砼正式合同.doc
- 商圈研究调研方案.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
