i want use multi layer Perceptron not using nntool using this code

[inputfilename, filePath] = uigetfile({'*.slx';'*.xls';'*.xlsx'},'Select File ');
% check if file selected
if isequal([inputfilename,filePath],[0,0])
errordlg('No File selected','File Error');
return
% load the file
else
inputfilename= fullfile(filePath,inputfilename);
% cehek if the file is excel formate
if isempty(xlsfinfo(inputfilename))
errordlg('Excel Filename must be specified');
return
else
%input = [[0; 0] [0; 1] [1; 0] [1; 1]];
%output = [0 1 1 0];
sheet = 1;
input = xlsread(inputfilename,sheet);
sheet = 2;
output = xlsread(inputfilename,sheet);
net = newff(input,output, [5,1], {'tansig','purelin'},'traingd');
net.trainParam.show = 50; % The result is shown at every 50th iteration (epoch)
net.trainParam.lr = 0.05; % Learning rate used in some gradient schemes
net.trainParam.epochs =1000; % Max number of iterations
net.trainParam.goal = 1e-3; % Error tolerance; stopping criterion
%Train network
net1 = train(net, input, output);
end
end
====================================================================
i read data from excel and have 2 sheet one as input(2 column) and the other as output(one column)
but i get this error : *Inputs and targets have different numbers of samples.*
but if i read the data from workspace like :
input = [[0; 0] [0; 1] [1; 0] [1; 1]];
output = [0 1 1 0];
it work fine how i can resolve this and thanks in advance i want read data from excel and call Multi layer Perceptron

1 件のコメント

Greg Heath
Greg Heath 2016 年 12 月 6 日
Perceptron is misspelled in the title and in the text.

サインインしてコメントする。

 採用された回答

Greg Heath
Greg Heath 2016 年 12 月 8 日

0 投票

After reading the EXCEL files you have to convert them to MATLAB matrices with sizes
[ I N ] = size(input)
[ O N ] = size(target)
Thank you for formally accepting my answer
Greg

5 件のコメント

khalid alsediri
khalid alsediri 2016 年 12 月 8 日
thanks you for your answer just i need to clarify this
[ I N ] = size(input) [ O N ] = size(target)
what is I N and O N is it variable or what can i put it like this [ input] = size(input) [ target] = size(target)
Greg Heath
Greg Heath 2016 年 12 月 10 日
The two matrix equations I gave you only produce the following information:
The data consists of N pairs of I dimensional "I"nputs
and corresponding O dimensional "O"utput targets
The equations should follow the statements that read in the data and assign them to the two data matrices.
I have posted zillions of examples in both the NEWSREADER and ANSWERS
They are not hard to find
Greg
khalid alsediri
khalid alsediri 2016 年 12 月 10 日
thanks you very much i search before i post this thanks you i kindly if u have such answer or link to that can post it i want read it
Greg Heath
Greg Heath 2016 年 12 月 11 日
What keywords were used in the search?
Greg Heath
Greg Heath 2016 年 12 月 13 日
_Search the NEWSREADER using
[ I N ] = size(input)
which yields the dimensions of the "I"nput matrix.
Similarly, search
[ O N ] = size(target)
which yields the dimensions of the "O"utput target matrix.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by