Skip to content

Instantly share code, notes, and snippets.

@palcu
Created April 22, 2015 10:33
Show Gist options
  • Save palcu/8d6473e6f2f5fc242f25 to your computer and use it in GitHub Desktop.
Save palcu/8d6473e6f2f5fc242f25 to your computer and use it in GitHub Desktop.
function [ ] = pr2()
m = 50;
for punct = 1:m
X(1, punct) = unifrnd(-1, 1);
X(2, punct) = unifrnd(-1, 1);
X(3, punct) = unifrnd(-1, 1);
end
for punct = 1:m
determinant = 2 * X(1, punct) - X(2, punct) + X(3, punct)
clasa = (determinant < 0)
if (clasa)
T(punct) = -1;
else
T(punct) = 1;
end
end
neuralnet1 = newp([-1 1; -1 1; -1 1], 1, 'hardlims', 'learnpn');
neuralnet1.adaptParam.passes = 1000
neuralnet1.adaptParam.showWindow = false;
neuralnet1 = adapt(neuralnet1, X, T);
plotpv(X, hardlim(T));
plotpc(neuralnet1.IW{1, 1}, neuralnet1.b{1});
Y1 = confusionmat(hardlim(T), hardlim(sim(neuralnet1, X)))
neuralnet2 = newp([-1 1; -1 1; -1 1], 1, 'hardlims', 'learnp');
neuralnet2.adaptParam.passes = 1000
neuralnet2.adaptParam.showWindow = false;
neuralnet2 = adapt(neuralnet2, X, T);
plotpv(X, hardlim(T));
plotpc(net.IW{1, 1}, net.b{1});
Y2 = confusionmat(hardlim(T), hardlim(sim(neuralnet2, X)))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment