Permalink
Browse files

added function findDeltas to find the deltas by backpropagation

  • Loading branch information...
1 parent cb105cd commit 112b801b938a377e7cd1af822507877c5262e12b @nflip committed with marcoeilers Mar 15, 2012
Showing with 25 additions and 0 deletions.
  1. +25 −0 handin3/findDeltas.m
View
25 handin3/findDeltas.m
@@ -0,0 +1,25 @@
+function d = findDeltas(Ws, actD, target, out, As)
+%%
+%% finds deltas in backpropagation
+%%
+%% Arguments:
+%% Ws: weights
+%% actD: derivative of activation function for hidden layer
+%% target: target value
+%% out: output value of NN
+%% As: vector of a_{i}
+%%
+%% Result:
+%% d = vector of deltas. idx(0) and idx(1) will be 0
+%%
+ lastIdx = size(Ws, 1)
+ d = [zeros(lastIdx - 1, 1); out-target];
+
+
+ %% find deltas only for hidden layer
+ for i = (lastIdx -1) : -1 : idx(2)
+ i
+ x = Ws(i+1:lastIdx, i) .* d(i+1:lastIdx)
+ d(i) = actD(As(i)) * sum(x)
+ end
+

0 comments on commit 112b801

Please sign in to comment.