-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathv2Gv_mainStep.m
56 lines (37 loc) · 1016 Bytes
/
v2Gv_mainStep.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
function [W1_2hat, W2_2hat] = v2Gv_mainStep(g0,g1,g2,h1,W1_1,W2_1,W1,W2)
% first calculate g2_2hat = g2_1
g0_1 = 0*g0;
%size(g0_1)
%size(W1)
%size(W1_1)
%size(g0)
h1_1 = W1*g0_1 + W1_1*g0;
g1_1 = h1_1;
%[h1_n,~] = size(h1);
%disp(h1_n);
%for i = 1:h1_n
% if (h1(i) == 0)
% g1_1(i) = 0;
% end
%end
%disp(size(W2));
%disp(size(g1_1));
%disp(size(W2_1*g1));
h2_1 = W2*g1_1 + W2_1*g1;
%---------------------------softmax changes here-------------------------
g2_1 = (g2.*(ones(size(g2)) - g2)).*h2_1;
g2_2hat = g2_1;
% now calculate the final product
%---------------------------softmax changes here-------------------------
h2_2hat = g2_2hat.*(g2.*(ones(size(g2)) - g2));
g1_2hat = W2.'*h2_2hat;
W2_2hat = h2_2hat*g1.';
h1_2hat = g1_2hat; %times ones and zeros
%[h1_n,~] = size(h1);
%for i = 1:h1_n
% if (h1(i) == 0)
% h1_2hat(i) = 0;
% end
%end
%this should be an average, not everything else
W1_2hat = h1_2hat*g0.';