طالب مسااااااااااااااااعده النجده

أنا عندي مشروع للكشف عن خلايا سرطان الثدي
وعندي كود اريد تصحيحه ودائما انفذه عن طريق m file يظهر خطأ في السطر 116 ولكن اذا نفذته عن طريق figure file ينفذ
[FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] varargout = interface3(varargin)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% INTERFACE3 M-file for interface3.fig
% INTERFACE3, by itself, creates a new INTERFACE3 or raises the existing
% singleton*.
% H = INTERFACE3 returns the handle to a new INTERFACE3 or the handle to
% the existing singleton*.
% INTERFACE3(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in INTERFACE3.M with the given input arguments.
% INTERFACE3(‘Property’,‘Value’,…) creates a new INTERFACE3 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before interface3_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to interface3_OpeningFcn via varargin.
% *See GUI Options on GUIDE’s Tools menu. Choose “GUI allows only one
% instance to run (singleton)”.
% See also: GUIDE, GUIDATA, GUIHANDLES
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help interface3
% Last Modified by GUIDE v2.5 16-Apr-2008 00:34:37
% Begin initialization code - DO NOT EDIT[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]gui_Singleton = 1;
gui_State = struct([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_Name’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], mfilename, [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_Singleton’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], gui_Singleton, [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_OpeningFcn’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], @interface3_OpeningFcn, [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_OutputFcn’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], @interface3_OutputFcn, [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_LayoutFcn’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], [] , [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘gui_Callback’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], []);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] nargin && ischar(varargin{1})[/COLOR]
gui_State.gui_Callback = str2func(varargin{1});[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end
if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] nargout[/COLOR]
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]else[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]gui_mainfcn(gui_State, varargin{:});[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% End initialization code - DO NOT EDIT
% — Executes just before interface3 is made visible.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] interface3_OpeningFcn(hObject, eventdata, handles, varargin)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to interface3 (see VARARGIN)
% Choose default command line output for interface3[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]handles.output = hObject;[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% Update handles structure[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]guidata(hObject, handles);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% UIWAIT makes interface3 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] varargout = interface3_OutputFcn(hObject, eventdata, handles) [/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]varargout{1} = handles.output;[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] edit1_Callback(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,‘String’) returns contents of edit1 as text
% str2double(get(hObject,‘String’)) returns contents of edit1 as a double
% — Executes during object creation, after setting all properties.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] edit1_CreateFcn(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] ispc && isequal(get(hObject,[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘BackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000]), get(0,[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘defaultUicontrolBackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000]))[/COLOR]
set(hObject,[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘BackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘white’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end
function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] edit2_Callback(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,‘String’) returns contents of edit2 as text
% str2double(get(hObject,‘String’)) returns contents of edit2 as a double
% — Executes during object creation, after setting all properties.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] edit2_CreateFcn(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] ispc && isequal(get(hObject,[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘BackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000]), get(0,[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘defaultUicontrolBackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000]))[/COLOR]
set(hObject,[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘BackgroundColor’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘white’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% — Executes on button press in pushbutton1.[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] pushbutton1_Callback(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% — Executes on button press in pushbutton1.
%________________________________________________________________________[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]data = load([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘BreastCancerTrain.txt’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]); [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%load the training data (in array called data)
%Normalise the data[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]data = Normalize(data);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%Make sure the classes are labeled from 1,…,C
% if min(data(:,d+1)) == 0
% data(:,d+1) = data(:,d+1)+1;
% end %if[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][row col]= size(data);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%Define training data[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]d = col-1; [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%dimensionality[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]C = 4; [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%number of classes[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]N = row; [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the number of observations in the training set
%Define the classifier
%If lr is constant, convergence is not guarenteed
%Can choose lr = 1/stepno to ensure convergence, the convergence may
%however be very slow
%learning parameter for the gradient-descent procedure[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]lr = 0.01;[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%for seq
%lr = 0.12;%for bat[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]maxepochs=str2double(get(handles.edit1,[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘String’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]));[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] isnan(maxepochs)[/COLOR]
errordlg([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘You must enter a numbric value’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Bad input’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘modal’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5])[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]M=str2double(get(handles.edit2,[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘String’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]));[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] isnan(M)[/COLOR]
errordlg([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘You must enter a numbric value’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Bad input’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘modal’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5])[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%Update of weights[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]update = [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘seq’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]; [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%either ‘seq’-sequential or ‘bat’-batch
%Weight initialisation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]clcov=get_clcov(data);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%get class covariances
%determine average class covariance[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]avgcov = zeros(d,d);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] citr=1:C[/COLOR]
avgcov = avgcov+clcov{citr};[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]avgcov = avgcov./C;[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%determine average class standard deviation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sd = 0;[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] sitr=1:d[/COLOR]
sd = sd+avgcov(sitr,sitr);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sd = sd./d;
delt = 1;[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%[Mxd]
%getsigns generates an [nxm] matrix with random -1’s and 1’s[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wji = (getsigns(M,d).*delt).*rand(M,d);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%initialise first layer of weights with values [-delt,delt]
%[CxM][/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wkj = (getsigns(C,M).*delt).*rand(C,M);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%initialise second layer of weights with values [-delt,delt]
%initialise the bias unit weights[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wji0 = getsigns(1,1).*delt.*rand();
wkj0 = getsigns(1,1).*delt.*rand();[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]%Feed_Forward stage
%The output of the jth hidden unit is obtained by first forming a weighted
%linear combination of the d input values and adding a bias
%An extra input variable x0 may be included with constant value x0=1 to
%absorb the bias into the weights[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] epoch=1:maxepochs[/COLOR]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%fprintf(‘Epoch: %g
’,epoch);[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sumji = zeros(M,d);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%sum of layer 1 deltaj(j,1)*x(i)[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sumkj = zeros(C,M);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%sum of layer 2 deltak(j,1)*zj(j,1)[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]acnt = 0;[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%accuracy counter[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] n=1:N
x = data(n,1:d);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%copy the obsn’th observation into array x[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Use a 1-to-C coding scheme[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%e.g. 1 = [1 0 0]’, 2 = [0 1 0]’, 3 = [0 0 1]’[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]tk = zeros(C,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Classes are coded from 1,…,C[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]tkval = data(n,d+1);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the class of the observation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]tk(tkval,1) = 1;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the weighted sum for each hidden layer unit[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%x is a single observation from the training set[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]aj = zeros(M,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
wsum = 0;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] i=1:d
wsum = wsum + wji(j,i)x(i);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%i[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wsum = wsum + wji0
1;[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%add the bias term[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]aj(j,1)=wsum;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%j[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the activations/outputs of the hidden layer nodes[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]zj = zeros(M,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
zj(j,1) = gsig(aj(j,1));
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%The outputs of the network are obtained by transforming the activations of[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the hidden units using a second layer of processing units[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%For each output unit k, we construct a linear combination of the outputs[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%of the hidden units[/LEFT]

[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the weighted sum of the output layer nodes[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]ak = zeros(C,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
wsum = 0;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
wsum = wsum + wkj(k,j)zj(j,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%i[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wsum = wsum + wkj0
1;[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%add the bias[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]ak(k,1)=wsum;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%j[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%The output/activation of the kth output unit is then obtained by[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%transforming this linear combination using a non-linear activation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%function (This activation function may be different from the activation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%function used in the hidden layer)[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the activations/outputs of the output layer nodes[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]yk = zeros(C,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
yk(k,1) = gsig(ak(k,1));
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%yk - response of output unit k[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%tk - corresponding target value for a particular input pattern xn[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the standard sum-of-squares error for the n’th pattern/observation[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]esum=0;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
esum = esum + (yk(k) - tk(k))^2;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]En(n)=0.5*esum;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%delta’s for output units[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]deltak =zeros(C,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
deltak(k,1) = yk(k) - tk(k);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the delta’s for the hidden units are given by[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]deltaj = zeros(M,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
jsum=0;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
jsum = jsum + wkj(k,j)deltak(k,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]deltaj(j,1) = zj(j,1)
(1-zj(j,1))jsum;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%The derivatives with respect to the first-layer and second-layer weights[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the dwji values and update wji[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Update the first layer weights - add the delta values to wji[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] i=1:d
dwji(j,i) = -lr
deltaj(j,1)*x(i);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] update == [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘seq’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%update the weights[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if j==1&i==1 fprintf(‘Updating 1st layer weights!
’);end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wji(j,i) = wji(j,i)+dwji(j,i);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sumji(j,i) = sumji(j,i) + deltaj(j,1)x(i);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%and the weights for the second layer are updated using[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
dwkj(k,j) = -lr
deltak(k,1)*zj(j,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] update == [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘seq’[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if k==1& j==1 fprintf(‘Updating 2nd layer weights!
’);end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]wkj(k,j) = wkj(k,j)+dwkj(k,j);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]sumkj(k,j) = sumkj(k,j) + deltak(k,1)zj(j,1);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%choose an observation of each class to monitor covergence of classes[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] (n==1|n==N|n==75)&(mod(epoch,500)==0)
fprintf([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘After %g epochs:
’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], epoch);
fprintf([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Error for pattern %g = %g
’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],n, En(n));
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]cloutp = zeros(1,C);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the classifier output[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]toutp = zeros(1,C);[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%the tatget output[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
cloutp(1,k)=yk(k);
toutp(1,k)=tk(k);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][clv cli]=max(cloutp);
[tv ti]=max(toutp);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] cli==ti
acnt = acnt+1;[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%correct label[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%n=1:N[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%Calculate the accuracy for this epoch[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] (mod(epoch,500)==0)
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%cloutp %the classifier output[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%toutp %the tatget output[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]eacc = acnt/N
100;
fprintf([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Classification accuracy is: %g
’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5], eacc);
ep_acc(epoch/100)=eacc;
axes(handles.axes1);
xp=[1:epoch];
yp=ep_acc(epoch/100);
plot(xp,yp)
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]

[LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%For batch learning:[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] update == [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘bat’[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] i=1:d
dwji(j,i) = -lrsumji(j,i);
wji(j,i) = wji(j,i)+dwji(j,i);
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%and the weights for the second layer are updated using[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] k=1:C
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]for[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5] j=1:M
dwkj(k,j) = -lr
sumkj(k,j);
wkj(k,j) = wkj(k,j)+dwkj(k,j);

[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%if update == ‘bat’[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22]%epochs[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]function[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] pushbutton2_Callback(hObject, eventdata, handles)[/COLOR][/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#228b22][LEFT]% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT]button=questdlg([/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Do you want to exit?’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]…[/LEFT]
[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][LEFT][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Exit’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Yes’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘No’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘No’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5]);[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]switch[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#000000] button[/COLOR]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘Yes’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],
exit;
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]‘No’[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5],
quit [/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#a020f0]cancel[/COLOR][/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5];[/LEFT]
[/SIZE][/FONT][FONT=Monotype Corsiva][SIZE=5][COLOR=#0000ff][LEFT]end[/LEFT]

[/COLOR][/SIZE][/FONT]

ربنا يوفقك إلى الحل يا أخي … و لكن رأيي إنك تحاول تنسق البرنامج في شكل أحسن من كده علشان يكون سهل إن إخواننا يقدروا يفهموه لأنه طويل … أقترح عليك إنك تكتبه أولا على أى برنامج كتابة نصوص مثل ال word و بعذ ذلك ضعه في المرفقات