%%%%%%%%%%%%%%%%%%%%%%%%This is the demo for the bls models including the
%%%%%%%%%%%%%%%%%%%%%%%%proposed incremental learning algorithms when the
%%%%%%%%%%%%%%%%%%%%%%%%memory of PC is not sufficient%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%load the dataset MNIST dataset%%%%%%%%%%%%%%%%%%%%
clear;
warning off all;
format compact;
load mnist;
%%%%%%%%%%%%%%%the samples from the data are normalized and the lable data
%%%%%%%%%%%%%%%train_y and test_y are reset as N*C matrices%%%%%%%%%%%%%%
train_x = double(train_x/255);
train_y = double(train_y);
% test_x = double(train_x/255);
% test_y = double(train_y);
test_x = double(test_x/255);
test_y = double(test_y);
train_y=(train_y-1)*2+1;
test_y=(test_y-1)*2+1;
assert(isfloat(train_x), 'train_x must be a float');
assert(all(train_x(:)>=0) && all(train_x(:)<=1), 'all data in train_x must be in [0:1]');
assert(isfloat(test_x), 'test_x must be a float');
assert(all(test_x(:)>=0) && all(test_x(:)<=1), 'all data in test_x must be in [0:1]');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the one shot BLS demo');
pause
%%%%%%%%%%%%%%%%%%%%This is the model of broad learning sytem with%%%%%%
%%%%%%%%%%%%%%%%%%%%one shot structrue%%%%%%%%%%%%%%%%%%%%%%%%
C = 2^-30; s = .8;%the l2 regularization parameter and the shrinkage scale of the enhancement nodes
N11=10;%feature nodes per window
N2=10;% number of windows of feature nodes
N33=50;% number of enhancement nodes
epochs=1;% number of epochs
train_err=zeros(1,epochs);test_err=zeros(1,epochs);
train_time=zeros(1,epochs);test_time=zeros(1,epochs);
% rand('state',67797325) % 12000 %%%%% The random seed recommended by the
% reference HELM [10].
N1=N11; N3=N33;
for j=1:epochs
[TrainingAccuracy,TestingAccuracy,Training_time,Testing_time] = bls_train(train_x,train_y,test_x,test_y,s,C,N1,N2,N3);
train_err(j)=TrainingAccuracy * 100;
test_err(j)=TestingAccuracy * 100;
train_time(j)=Training_time;
test_time(j)=Testing_time;
end
save ( ['mnist_result_oneshot_' num2str(N3)], 'train_err', 'test_err', 'train_time', 'test_time');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the one shot BLS demo with BP algorithm');
pause
%%%%%%%%%%%%%%%%%%%This is the model of broad learning system for one%%%%%%
%%%%%%%%%%%%%%%%%%%shot structrue with fine tuning under BP algorithm%%%%%%%%%%%%%%%%%%%%%%%%
C = 2^-30; s = .8;%the l2 regularization parameter and the shrinkage scale of the enhancement nodes
N11=10;%feature nodes per window
N2=10;% number of windows of feature nodes
N33=1000;% number of enhancement nodes
epochs=1;% number of epochs
train_err=zeros(1,epochs);test_err=zeros(1,epochs);
train_time=zeros(1,epochs);test_time=zeros(1,epochs);
% rand('state',67797325) % 12000 %%%%% The random seed recommended by the
% reference HELM [10].
N1=N11; N3=N33;
for j=1:epochs
[TrainingAccuracy,TestingAccuracy,Training_time,Testing_time] = bls_train_bp(train_x,train_y,test_x,test_y,s,C,N1,N2,N3);
train_err(j)=TrainingAccuracy * 100;
test_err(j)=TestingAccuracy * 100;
train_time(j)=Training_time;
test_time(j)=Testing_time;
end
save ( ['mnist_result_bp_' num2str(N3)], 'train_err', 'test_err', 'train_time', 'test_time');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the BLS demo for increment of m enhancement nodes');
pause
%%%%%%%%%%%%%%%%%%%%This is the model of broad learning system for%%%%%%
%%%%%%%%%%%%%%%%%%%%increment of m enhancement nodes%%%%%%%%%%%%%%%%%%%%%%%%
C = 2^-30; s = .8;%the l2 regularization parameter and the shrinkage scale of the enhancement nodes
N11=10;%feature nodes per window
N2=10;% number of windows of feature nodes
N33=300;% number of enhancement nodes
m=50;%number of enhancement nodes in each incremental learning
l=5;% steps of incremental learning
epochs=1;% number of epochs
% rand('state',67797325) % 12000 %%%%% The random seed recommended by the
% reference HELM [10].
N1=N11; N3=N33;
[train_err,test_err,train_time,test_time,Testing_time,Training_time] = bls_train_enhance(train_x,train_y,test_x,test_y,s,C,N1,N2,N3,epochs,m,l);
save ( ['mnist_result_enhance'], 'train_err', 'test_err', 'train_time', 'test_time','Testing_time','Training_time');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the BLS demo for increment of m2+m3 enhancement nodes and m1 feature nodes');
pause
%%%%%%%%%%%%%%%%%%%%This is the model of broad learning system for%%%%%%
%%%%%%%%%%%%%%%%%%%%increment of m2+m3 enhancement nodes and m1 feature nodes %%%%%%%%%%%%%%%%%%%%%%%%
C = 2^-30;%the regularization parameter for sparse regualarization
s = .8;%the shrinkage parameter for enhancement nodes
N11=10;%feature nodes per window
N2=6;% number of windows of feature nodes
N33=300;% number of enhancement nodes
epochs=1;% number of epochs
m1=10;%number of feature nodes per increment step
m2=15;%number of enhancement nodes related to the incremental feature nodes per increment step
m3=35;%number of enhancement nodes in each incremental learning
l=5;% steps of incremental learning
train_err_t=zeros(epochs,l);test_err_t=zeros(epochs,l);train_time_t=zeros(epochs,l);test_time_t=zeros(epochs,l);
Testing_time_t=zeros(epochs,1);Training_time_t=zeros(epochs,1);
% rand('state',67797325) % 12000 %%%%% The random seed recommended by the
% reference HELM [10].
N1=N11; N3=N33;
for i=1:epochs
[train_err,test_err,train_time,test_time,Testing_time,Training_time] = bls_train_enhancefeature(train_x,train_y,test_x,test_y,s,C,N1,N2,N3,m1,m2,m3,l);
train_err_t(i,:)=train_err;test_err_t(i,:)=test_err;train_time_t(i,:)=train_time;test_time_t(i,:)=test_time;
Testing_time_t(i)=Testing_time;Training_time_t(i)=Training_time;
end
save ( [ 'mnist_result_enhancefeature'], 'train_err_t', 'test_err_t', 'train_time_t', 'test_time_t','Testing_time_t','Training_time_t');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the BLS demo for increment of m input patterns');
pause
%%%%%%%%%%%%%%%%%%%%This is the model of broad learning system for%%%%%%
%%%%%%%%%%%%%%%%%%%% increment of m input patterns %%%%%%%%%%%%%%%%%%%%%%%%
train_xf=train_x;train_yf=train_y;
train_x=train_xf(1:10000,:);train_y=train_yf(1:10000,:); % the selected input patterns of int incremental learning
C = 2^-30;%the regularization parameter for sparse regualarization
s = .8;%the shrinkage parameter for enhancement nodes
N11=10;%feature nodes per window
N2=10;% number of windows of feature nodes
N33=500;% number of enhancement nodes
epochs=1;% number of epochs
m=10000;%number of added input patterns per increment step
l=6;% steps of incremental learning
train_err_t=zeros(epochs,l);test_err_t=zeros(epochs,l);train_time_t=zeros(epochs,l);test_time_t=zeros(epochs,l);
Testing_time_t=zeros(epochs,1);Training_time_t=zeros(epochs,1);
% rand('state',67797325) % 12000 %%%%% The random seed recommended by the
% reference HELM [10].
N1=N11; N3=N33;
for i=1:epochs
[train_err,test_err,train_time,test_time,Testing_time,Training_time] = bls_train_input(train_x,train_y,train_xf,train_yf,test_x,test_y,s,C,N1,N2,N3,m,l);
train_err_t(i,:)=train_err;test_err_t(i,:)=test_err;train_time_t(i,:)=train_time;test_time_t(i,:)=test_time;
Testing_time_t(i)=Testing_time;Training_time_t(i)=Training_time;
end
save ( [ 'mnist_result_input'], 'train_err_t', 'test_err_t', 'train_time_t', 'test_time_t','Testing_time_t','Training_time_t');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
disp('Press any key to run the BLS
没有合适的资源?快使用搜索试试~ 我知道了~
BLS宽度学习matlab代码.zip
共19个文件
m:17个
mat:2个
4星 · 超过85%的资源 需积分: 48 55 下载量 3 浏览量
2019-08-01
10:14:29
上传
评论 6
收藏 77.82MB ZIP 举报
温馨提示
人工智能里的 宽度学习,该代码为matlab版本,有空可以比较深度学习
资源推荐
资源详情
资源评论
收起资源包目录
BLS.zip (19个子文件)
Demo_Broadlearning_norb
norb.mat 63.84MB
BLS_demo_norb.m 2KB
pre_zca.m 438B
result.m 72B
BLS_demo_norb_for_lower_memory.m 2KB
bls_train.m 3KB
sparse_bls.m 495B
Demo_Broadlearning_MNIST
bls_train_enhancefeature.m 7KB
mnist.mat 14.05MB
pre_zca.m 438B
BLS_demo_MNIST.m 9KB
result.m 72B
bls_train_inputenhance.m 6KB
BLS_demo_MNIST_for_lower_memory.m 10KB
bls_train.m 3KB
sparse_bls.m 495B
bls_train_bp.m 8KB
bls_train_input.m 6KB
bls_train_enhance.m 6KB
共 19 条
- 1
资源评论
- buaasuozi2019-09-19包含了用于 MNIST 和 NORB 的测试程序 CSDN上有其他分开形式的代码可以下载,我就下载重复了
baby12511
- 粉丝: 7
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功