-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevaluateMLP.m
26 lines (24 loc) · 886 Bytes
/
evaluateMLP.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function output = evaluateMLP(activationFunction,Weights, Sample,bias)
% Evaluates the MLP
%INPUT :- activationFunction, Weights :- weight matrix ; Sample :- input
%example on which to evauate
%OUTPUT :- output final result vector after passing through network
%Forward Pass
noOfHiddenUnits = length(Weights)+1;
ActualInput = cell(1,noOfHiddenUnits);
ActualOutput = cell(1,noOfHiddenUnits);
%inputVector = inputValues(:, n(k));
ActualInput{1} = Sample;
%ActualInput{1} = inputValues(:, n);
ActualOutput{1} = ActualInput{1};
for j = 2 : noOfHiddenUnits
ActualInput{j} = Weights{j-1}*ActualOutput{j-1};
ActualOutput{j} = activationFunction(ActualInput{j});
if(bias)
if(j~=noOfHiddenUnits)
ActualOutput{j}(end) = 1;
end
end
end
output = ActualOutput{noOfHiddenUnits};
end