Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
35 views4 pages

Neural Network for Fruit Classification

This document describes a neural network program that classifies points as apples or oranges. It creates a perceptron model with a plane dividing the classifications in 3D space. It shows test points for an orange and apple being correctly classified. The code to generate the neural network and 3D plot is also included. The program then runs in a loop, prompting the user to input new test points and displaying the corresponding classification.

Uploaded by

Eduard Stark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views4 pages

Neural Network for Fruit Classification

This document describes a neural network program that classifies points as apples or oranges. It creates a perceptron model with a plane dividing the classifications in 3D space. It shows test points for an orange and apple being correctly classified. The code to generate the neural network and 3D plot is also included. The program then runs in a loop, prompting the user to input new test points and displaying the corresponding classification.

Uploaded by

Eduard Stark
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Name: Vélez Cortés Eduardo Arturo

Group: 2MM12 Date: 20/04/2020

Practice 3: Neural Networks Perceptron


In this practice we create a neuronal network used to classify among apples and oranges.
The next figure shows the 3D plot of the plane that divides both sides of the classification.

If we insert the point blue of the image, in the side of the oranges we obtain the valued
that we imagined.
Name: Vélez Cortés Eduardo Arturo
Group: 2MM12 Date: 20/04/2020

With the vector of the other point we obtain the apple:


Name: Vélez Cortés Eduardo Arturo
Group: 2MM12 Date: 20/04/2020

Here is the code used to generate this program:


clear all;
close all;
clc;

P1=[1 -1 -1]; %The orange side


P2=[1 1 -1]; %The apple side
P=[P1 ; P2]
T=[-1 1];
[m,n]=size(P)
N=1;
W=rand(N,n)
b=rand(N,1)
Name: Vélez Cortés Eduardo Arturo
Group: 2MM12 Date: 20/04/2020
epoch= input('Iteration Number: ') % -- ask the user --
for i=1:epoch
for j=1:2
a= hardlims(W*[P(j,1);P(j,2);P(j,3)]+b);
e= T(j)-a;
wnew = W + e*[P(j,1) P(j,2) P(j,3)];
bnew = b + e;
W= wnew;
b= bnew;
end
end

%% 3d plot
[x,y] = meshgrid(-2:0.1:2);
pv = [0,-(b/W(2)),0];
ph = [-(b/W(1)),0,0];
pz = [0,0,-(b/W(3))];

Phv= pv-ph;
Phz= pz-ph;
Vn= cross(Phv, Phz);
z = ( Vn(1)*(x-ph(1)) + Vn(2)*y )/( Vn(3) );

figure (1)
hold on;
surf (x,y,z)
plot3 (1,-1,-1, 'b o');
plot3 (1,1,-1, 'r o');
xlabel('x');
ylabel('y');
zlabel('z');

%% While cycle
desition = 1;
while (desition == 1)
Vector = input('Introduce the point value among [], and in a vector form:
')
Pi = Vector;
a=hardlims(W*[Pi(1,1);Pi(1,2);Pi(1,3)]+b);
if a == -1
imshow('Orange.jpeg');
else
imshow('Apple.jpeg');
end
desition = input('Again (yes:1 No:0): ')
end

You might also like