-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauf71.m
More file actions
50 lines (40 loc) · 713 Bytes
/
auf71.m
File metadata and controls
50 lines (40 loc) · 713 Bytes
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
clear all;
close all;
clc;
% Daten
X = [0,0; 0,1; 1,0; 1,1];
y = [0;1;1;0];
% Lernkonstante
gamma = 2;
% Fehlerschwelle
epsilon = 0.01;
% random weights
W1_hat = rand(3,2);
W2_hat = rand(3,1);
count = 0;
do
count += 1;
E = 0;
dW1_hat = 0;
dW2_hat = 0;
for(i=1:4)
[grad1,grad2,error] = backprop(X(i,:),W1_hat,W2_hat,y(i));
E += error;
dW1_hat += -gamma * grad1;
dW2_hat += -gamma * grad2;
endfor
Es(count) = E;
% endgültiges Update(offline Backprop)
W1_hat += dW1_hat;
W2_hat += dW2_hat;
until(E < epsilon)
%Plotte Fehler über Anzahl der Iterationen
plot(Es);
hits = 0;
for(i=1:4)
class = classify(W1_hat,W2_hat,X(i,:))
if(class == y(i))
hits += 1;
endif
end
ER = hits/4 *100