Implemented NOR function

This commit is contained in:
Sam Perry
2016-11-08 22:08:38 +00:00
parent 867de8995f
commit 84466fd2b7
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -8,7 +8,6 @@
% after normalising we add the bias
%X=[ones(size(X,1),1),X];
X=[ones(size(X,1),1),X,X(:,1).*X(:,2),X(:,1).^2,X(:,2).^2];
theta=ones(1,size(X,2));
% for question 7, modify the dataset X to have more features (in each row)
@@ -18,6 +17,7 @@ theta=ones(1,size(X,2));
% here append x_2 * x_2 (remember that x_1 is the bias)
% here append x_3 * x_3 (remember that x_1 is the bias)
X=[ones(size(X,1),1),X,X(:,1).*X(:,2),X(:,1).^2,X(:,2).^2];
% initialise theta
alpha = 0.05;
+3 -3
View File
@@ -86,9 +86,9 @@ classdef NeuralNetwork < handle
test_errors=[test_errors, NeuralNetwork.get_error(test_set_input,test_set_output,nn)];
end
end
%if mod(i , 10) == 0
% display([ 'cost = ',num2str(error)])
%end
if mod(i , 10) == 0
display([ 'cost = ',num2str(error)])
end
if exist('is_iris')
if is_iris
if mod(i, 100) == 0
+4 -4
View File
@@ -7,13 +7,13 @@ training_set_input = [
];
training_set_output = [
1;
0;
1;
1;
0
0;
1
];
[errors,nn,training_errors,test_errors] = NeuralNetwork.train(training_set_input,training_set_output,2,10000,1.0);
[errors,nn,training_errors,test_errors] = NeuralNetwork.train(training_set_input,training_set_output,2,10000, 7.0);
NeuralNetwork.test_xor(training_set_input,training_set_output,nn);
figure()
plot(errors)