-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathRBFneuron.m
68 lines (38 loc) · 1.62 KB
/
RBFneuron.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
64
65
66
67
68
classdef RBFneuron
properties
input;
output;
weights;
layer_length;
end
methods
function obj = RBFneuron(data)
obj.layer_length = length(data) + 1;
obj.weights = zeros(1, obj.layer_length);
for i = 1 : obj.layer_length - 1
obj.weights(i) = data(i);
end
obj.weights(obj.layer_length) = 10;
end
function obj = Activate(obj, data)
obj.input = Distance(obj, data);
out = exp(-(obj.input^2 / (2 * obj.weights(obj.layer_length)^2)));
obj.output = exp(-(obj.input^2 / (2 * obj.weights(obj.layer_length)^2)));
end
function r = Distance(obj, data)
len = length(data);
r = sqrt(sum((data - obj.weights(1 : len)).^2));
end
function [obj, maximum] = WeightsChange(obj, gamma, data)
for i = 1 : obj.layer_length - 1
delta = gamma * (data(i) - obj.weights(i));
obj.weights(i) = obj.weights(i) + delta;
if i == 1
maximum = abs(delta);
elseif abs(delta) > maximum
maximum = delta;
end
end
end
end
end