-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprocessing.m
63 lines (48 loc) · 1.14 KB
/
processing.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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
%Processing
function [error,w1,w2] = processing(~, inputx, weight1, weight2, bias1, bias2, targets, alpha)
% Applying Feed Forward
% Hidden Layer
neth = inputx * weight1;
neth = neth + bias1;
outh = sigm(neth);
% Output Layer
neto = outh * weight2;
neto = neto + bias2;
outo = sigm(neto);
% Error Phase
errora = targets - outo;
errorf = errora.^2;
errorf = 0.5 * errorf;
error = sum(errorf);
% Back Propogation
% Output Layer
iouto = 1 - outo;
en = -1 * errora;
iouto = iouto';
test = iouto * outo;
test = diag(test);
test = test * en;
test = diag(test);
change2 = test * outh;
change2 = change2';
change2 = alpha * change2;
% Hidden Layer
test = test';
w2 = weight2';
z = test * w2;
iouth = 1 - outh;
iouth = iouth';
p = iouth * outh;
p = diag(p);
p = p';
z = z';
temp = z * p;
temp = diag(temp);
q = inputx';
temp = temp';
change1 = q * temp;
change1 = alpha * change1;
% New Weights
w2 = weight2 - change2;
w1 = weight1 - change1;
end