function [IW,B,LW,TF,TYPE] = elmtrain(P,T,N,TF,TYPE)
% ELMTRAIN Create and Train a Extreme Learning Machine
% Syntax
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,N,TF,TYPE)
% Description
% Input
% P - Input Matrix of Training Set (R*Q)
% T - Output Matrix of Training Set (S*Q)
% N - Number of Hidden Neurons (default = Q)
% TF - Transfer Function:
% 'sig' for Sigmoidal function (default)
% 'sin' for Sine function
% 'hardlim' for Hardlim function
% TYPE - Regression (0,default) or Classification (1)
% Output
% IW - Input Weight Matrix (N*R)
% B - Bias Matrix (N*1)
% LW - Layer Weight Matrix (N*S)
% Example
% Regression:
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,20,'sig',0)
% Y = elmtrain(P,IW,B,LW,TF,TYPE)
% Classification
% [IW,B,LW,TF,TYPE] = elmtrain(P,T,20,'sig',1)
% Y = elmtrain(P,IW,B,LW,TF,TYPE)
% See also ELMPREDICT
% Yu Lei,11-7-2010
% Copyright www.matlabsky.com
% $Revision:1.0 $
if nargin < 2
error('ELM:Arguments','Not enough input arguments.');
end
if nargin < 3
N = size(P,2);
end
if nargin < 4
TF = 'sig';
end
if nargin < 5
TYPE = 0;
end
if size(P,2) ~= size(T,2)
error('ELM:Arguments','The columns of P and T must be same.');
end
[R,Q] = size(P);
if TYPE == 1
T = ind2vec(T);
end
[S,Q] = size(T);
% Randomly Generate the Input Weight Matrix
IW = rand(N,R) * 2 - 1;
% Randomly Generate the Bias Matrix
B = rand(N,1);
BiasMatrix = repmat(B,1,Q);
% Calculate the Layer Output Matrix H
tempH = IW * P + BiasMatrix;
switch TF
case 'sig'
H = 1 ./ (1 + exp(-tempH));
case 'sin'
H = sin(tempH);
case 'hardlim'
H = hardlim(tempH);
end
% Calculate the Output Weight Matrix
LW = pinv(H') * T';
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
Matlab是一种专业的数学计算软件,也可以被看作是一种编程语言,主要用于数值计算和科学计算。它是matrix(矩阵)和language(语言)两个词的缩写,寓意该软件旨在以矩阵为基础,方便快捷地进行各种数学计算和数据处理。 Matlab提供了简单易用的命令行窗口,可以用来输入和执行Matlab代码。它还提供了交互式命令历史记录和调用文件,可以方便用户记录和查看之前执行的命令。Matlab支持多种编程语言,包括Matlab、J Matlab和MEX Matlab,可以根据不同的需求选择不同的编程语言。 Matlab提供了丰富的工具箱,包括信号处理工具箱、图像处理工具箱、优化工具箱等,可以方便地进行各种数学计算和数据处理。Matlab还提供了Simulink模块库,可以用来构建自动控制系统、数字信号处理系统等。 Matlab的语法简单易懂,可以快速地进行数学计算和数据处理。Matlab支持函数式编程,可以使用函数来简化代码,提高代码的可读性和可维护性。Matlab还支持面向对象编程,可以使用类和对象来组织代码,提高代码的可重用性和可维护性。 总之,Matlab是一种功能强大的数学计算软件
资源推荐
资源详情
资源评论
收起资源包目录
Class_7_Code.zip (12个子文件)
Class_7_Code
elmtrain.m 2KB
iris_data.mat 1KB
elmpredict.m 1KB
html
main_spectra.png 4KB
main_iris.html 9KB
main_spectra_01.png 9KB
main_spectra.html 9KB
main_iris_01.png 8KB
main_iris.png 4KB
main_iris.m 2KB
spectra_data.mat 167KB
main_spectra.m 1KB
共 12 条
- 1
资源评论
大雄是个程序员
- 粉丝: 2768
- 资源: 571
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功