资源简介
改进的elm的matlab算法,该算法比原来的elm的算法在超过3个神经元后的计算速度能明显加快!原理是运用函数产生列矩阵…ELM 是一种快速的神经网络算法,本人已经比较过,比很多流行的算法(BP,SVM)都快,而且效果很好,运行环境是matlab
代码片段和文件信息
%%修改过的elm的matlab算法,该算法比原来的elm的算法在超过3个神经元后的计算速度能明显加快!原理是运用函数产生列矩阵!!
%%ELM 是一种快速的神经网络算法,本人已经比较过,比很多流行的算法(BPSVM)都快而且效果很好,运行环境是matlab,
%%可以测试所有的benchmark的数据
function [TrainingTime TrainingAccuracy TestingAccuracy] = elm_fun(TrainingData_File TestingData_File NumberofHiddenNeurons ActivationFunction Elm_Type)
% Usage: elm(TrainingData_File TestingData_File Elm_Type NumberofHiddenNeurons ActivationFunction)
% OR: [TrainingTime TestingTime TrainingAccuracy TestingAccuracy] = elm(TrainingData_File TestingData_File Elm_Type NumberofHiddenNeurons ActivationFunction)
%
% Input:
% TrainingData_File - Filename of training data set
% TestingData_File - Filename of testing data set
% Elm_Type - 0 for regression; 1 for (both binary and multi-classes) classification
% NumberofHiddenNeurons - Number of hidden neurons assigned to the ELM
% ActivationFunction - Type of activation function:
% ‘sig‘ for Sigmoidal function
% ‘sin‘ for Sine function
% ‘hardlim‘ for Hardlim function
%
% Output:
% TrainingTime - Time (seconds) spent on training ELM
% TestingTime - Time (seconds) spent on predicting ALL testing data
% TrainingAccuracy - Training accuracy:
% RMSE for regression or correct classification rate for classification
% TestingAccuracy - Testing accuracy:
% RMSE for regression or correct classification rate for classification
%
% MULTI-CLASSE CLASSIFICATION: NUMBER OF OUTPUT NEURONS WILL BE AUTOMATICALLY SET EQUAL TO NUMBER OF CLASSES
% FOR EXAMPLE if there are 7 classes in all there will have 7 output
% neurons; neuron 5 has the highest output means input belongs to 5-th class
%
% Sample1 regression: [TrainingTime TestingTime TrainingAccuracy TestingAccuracy] = elm(‘sinc_train‘ ‘sinc_test‘ 0 20 ‘sig‘)
% Sample2 classification: elm(‘diabetes_train‘ ‘diabetes_test‘ 1 20 ‘sig‘)
%
%%%% Authors: CHEN LEI
%%%% NANYANG TECHNOLOGICAL UNIVERSITY SINGAPORE
%%%% EMAIL: chen_lei@pmail.ntu.edu.sg
%%%% DATE: APRIL 2006
%%%%%%%%%%% Macro definition
REGRESSION=0;
CLASSIFIER=1;
%%%%%%%%%%% Load training dataset
train_data=load(TrainingData_File);
T=train_data(:1)‘;
P=train_data(:2:size(train_data2))‘;
clear train_data; % Release raw training data array
%%%%%%%%%%% Load testing dataset
test_data=load(TestingData_File);
TV.T=test_data(:1)‘;
TV.P=test_data(:2:size(test_data2))‘;
clear test_data; % Release raw testing data array
NumberofTrainingData=size(P2);
NumberofTestingData=size(TV.P2);
NumberofInputNeurons=size(P1);
if Elm_Type~=REGRESSION
%%%%%%%%%%%% Preprocessing the data of classification
sorted_target=s
- 上一篇:手势识别,基于MATLAB
- 下一篇:复合多尺度排列熵matlab代码
评论
共有 条评论