Skip to content

Commit

Permalink
get_output bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lmarzora committed May 10, 2017
1 parent 6a6fe40 commit 0f589b4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion multilayer_perceptron.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
for m = 2:M
layer_entry{m}(2:end) = activation_func(weights{m-1} * layer_entry{m-1}');
end
output(i) = activation_func(weights{M} * layer_entry{M}');
output(i) = (weights{M} * layer_entry{M}');
i = i + 1;
end
end
Expand Down Expand Up @@ -81,6 +81,12 @@
if error_per_iteration(iteration) <= tolerance
return
end
if error_per_iteration(iteration) <= 5e-4
learning_factor = .02;
end
if error_per_iteration(iteration) <= 4e-4
learning_factor = .01;
end
end

end
Expand Down
11 changes: 11 additions & 0 deletions plotter.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source multilayer_perceptron.m
for i = 1:length(x)
for j = 1:length(y)
z(i,j) = get_output([x(i);y(j)],weights,net,f);
end
end

plot3(terrain(:,1),terrain(:,2),terrain(:,3),'.','markersize',12)
hold on;
surf(x,y,z);
hold off;
4 changes: 2 additions & 2 deletions test.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
source multilayer_perceptron.m
terrain = dlmread('terrain/terrain03.data');
[f,fder] = activation_tanh(1);
net = [2,200,50,10,1];
[weights,output,mse] = multilayer_perceptron_learn(terrain(:,1:2)',terrain(:,3)',net ,f,fder,.05,1e4,2e-4);
net = [2,45,50,1];
[weights,output,mse] = multilayer_perceptron_learn(terrain(:,1:2)',terrain(:,3)',net ,f,fder,.05,5e4,2e-4);
x = [-3:0.01:3];
y = x;
%dlmwrite('weights.csv',cell2mat(weights));
Expand Down

0 comments on commit 0f589b4

Please sign in to comment.