Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
NETWORKS TRAINING
Diana Catalina Beltrn Huertas, Joan Sebastian Bonilla Guerra, and rik Steven Romero Martnez
Abstract The percentage of unwanted mails that access to each email account overpass the seventy percent of the total of emails.
This clearly will imply that the companies that provide those services generate an additional over cost to the companies.
Nowadays there are a lot of existing methods that are designed to detect spam, those methods can be classified into two groups, the
ones that are based on source that generated the mail and the ones that are based on the content thereof. The method that is used in
this document is based on the content of example emails, that will train a neural network with feedforward and multilayer perceptron.
with the purpose of detect any spam on the mail that access in the net.
In this article are compare different network topologies , different types of training and different activation functions in order to
reduce network error as much as possible.
I. INTRODUCTION
He spam emerge from the bad use of the email where the spammers send too much emails with spams. In the past years the
robots have been used more frequently in places where you have to take into account the environment where they work, it is
important the use of many sensor that allow us understand the actions that the robot will have to take. [1]
Statistics indicate that the percentage of spam entering each account clearly exceeds seventy percent of the total post.
They found different solutions to this problem but we will focus on solutions based on content analysis. In several proposed
solutions to the problem of spam filtering, some based on neural networks. [2]
This tool is inspired by biological nervous systems. As in nature a large network of neurons determine a function. Its
mandatory to understand how the neural networks performs its tasks, they typically are trained, adjusted so that a particular
stimulus at inputs of network leads to a specific target. Then the training consist on modify the weights of each input to get in the
network, until the output reach the target, or reach a boundary closed to the target defined by an error tolerance.
The fact is the neural networks need to accomplish three steps:
Learning: acquiring knowledge based on experience and practice. The neural network can shape their behavior according to
the environment, learning by changing the synaptic weights
Generalizing: abstracting what is common and essential to many things, to form a concept.
Abstracting: separated by an intellectual operation the qualities of an object to analyze them in isolation. [1]
(a) (b)
Figure 1. Common use of Neural Network Architectures.(a) Single (b)Multiple output
At the end the neural networks help systems to including pattern recognition, identification, classification, speech, vision, and
control systems, thus the areas is used covers financial, engineering, and other practical paradigms that are hard to solve for
human beings and conventional computers.
Implemented Neural network architecture Usually are feedforward networks over a spread of inputs. Anything using a general
approximation function. It can approximate any function with a finite number of discontinuities arbitrarily for a particular
number of outputs, depending on whether is defined sufficient neurons in the hidden layer(s).
This document will be organized as follow, in Section II the method will be detailed based on in Section III will described the
methodology used for training the neural network, and the code used to archive the problem. In section IV the results are
displayed and Section V establishes the conclusions of this work.
To define a fitting problem for the toolbox, is needed a set of q inputs vectors as columns ina matrix. then arrange another set of
Q target vectors, the correct output for each array in the matrix. In general the standard path for designing a neurla network to
solve problems can list in four areas:
- Function fitting
- Pattern Recognition
- Clustering
- Time series Analysis
1. Collect Data
2. Create The Network
3. Configure the Network
4. Initialize the Weight and the biases
5. Train the Network
6. Validate the Network
7. Use the Network
The hardest thing is to choose the correct number of neurons, or the most appropriate trainning algorithm, also the architechture
fixed to build the network. By the way Matlab offers some functions that allowes
Figure Log-Sigmoid Transfer Function
On the other hand, if you want to constrain the outputs of a network (such as between 0 and 1), then the output layer should use a
sigmoid transfer function (such as logsig). THis happens when the network is used for pattern recognition problems, making
decision over the networtk. In the other hand, multilayer networks can use the tan-sigmoid transfer function tansig.
%----------------------------------------------------------------------------------------------------
% NETWORK TRAINING
%----------------------------------------------------------------------------------------------------
close all
clc
clear all
x=load('spamTrain.mat');%CHARGING THE PARENT TRAINING
entreno=(x.X)';% SEPARATION OF THE RED (VALUES TRAINING)
label=(x.y)';% SEPARATION OF THE RED (VALUES OF THE TARGET)
nn=19;% NUMBER OF NEURONS IN INTERMEDIATE LAYERS
red=newff(minmax(entreno),[nn nn 1],{'tansig','tansig','purelin'},'traingda');% CREATION OF THE NETWORK
red=init(red);%INITIALIZING NETWORK OPTIMAL WITH THE VALUES FOR OPERATION
red.trainParam%PRINT PARAMETERS OF THE NETWORK
[red,entrenamiento]=train(red,entreno,label);% NETWORK TRAINING
T=1;
for i=1:4000
Z=rand;
if(T<=800)
if(Z>0.700)
prueba(:,T)=entreno(:,i);%800 MAILS ARE SEPARATED FROM THE TOTAL
labelprueba(T)=label(1,i);%IN THE WOMB OF TRAINING
T=T+1;
end
end
end
%for i=1:200
% prueba(:,i)=entreno(:,i);
% labelpruena(i)=label(:,i);
%end
reprueba=sim(red,prueba);% DELIVERY NETWORK IS SIMULATED WITH THE SEPARATED NUMBERS
error_train=mse(labelprueba-reprueba);% THE ERROR IS CALCULATED BETWEEN THE VALUES OBTAINED AND
EXPECTED
%% ------------------------------------------------------------------------------------------------
% TEST ALGORITHM
%--------------------------------------------------------------------------------------------------
load('spamTest.mat');% BURDEN OF PROOF MATRIX
test=sim(red,Xtest');%THE BEHAVIOR OF THE NETWORK IS THE NEW MATRIX SIMULATES
error_test=mse(ytest'-test);% It IS CALCULATED ERROR BETWEEN THE NETWORK AND THE MATRIX TEST
%%--------------------------------------------------------------------------------------------------
% CHECKING THE OPERATION
%---------------------------------------------------------------------------------------------------
r=randi(1000); % A RANDOM NUMBER ITS GENERATED
entrada=Xtest(r,:); % WITH YOU GET, AN EMAIL TEST
labelprueba=ytest(r);
salida=sim(red,entrada'); %ITS SIMULATED THE RESULT OF THE CREATED NET
if(salida>0) % SIGTH IF THE ANSWER OF THE NETWORK ITS SUCCESSFUL
disp('el correo es un spam')
else
disp('el correo no es un spam')
end
if(labelprueba==1)
disp('deberia ser un spam')
else
disp('deberia ser no spam')
end
IV. RESULTS
figure XXX
In the figure XXX, shows a neural network that use two intermediate layers, which threw the followings errors while the number
of neurons increased (Table 1).
n
neuron
as error
1 0,0356
3 0,0436
5 0,0379
7 0,0434
9 0,0451
11 0,0319
13 0,031
15 0,032
17 0,0325
19 0,0385
As we can see on the table 1, the neural network in the two intermediate layers were created with neuron fro 1 to 19, going two
by two. The generated error for each neuron was calculated using the square mean error, ranging between 0.03 and 0.04.
figure XXX
In the figure XXX it shows the multilayer perceptron, with one intermediate layer. the quantity of of the layer was change from 1
to 19, going two by two and the generated error for each neuron was calculated using the square mean error.
n
neuron
as error
1 0,0875
3 0,0714
5 0,0516
7 0,0564
9 0,053
11 0,0437
13 0,0542
15 0,0523
17 0,054
19 0,0495
table 2. errors for one intermediate layer
The table 2, shows that the generated error with a single neuron it has a high value near to 0.0875, in relation with the error
generated with a higher number of neurons.
In the following figure (figure XXX), a neural network is created with a single layer that work as a simple perceptron, 200 emails
were selected from the training net in a random way, and we obtain a error of 2.817 using the square mean error (table 3).
n neuronas error
1 2,817
table 3. Error for a single layer
The performance of the neural network, not only depends on the quantity of neurons and layers, it also depend of the type of
training that we use for the net.
- Training decrease gradient: In this type of training the synaptic weights and thresholds of neurons, it is updated
with each iteration, in the negative direction of the gradient of the performance function. Generating an average error of
0.0488 training in the training and the test 0.0597, for a multilayer neural network 2 intermediate layers of neurons 19
each.
- Learning training cup: With normal algorithm, the learning rate remains constant over time. The network
training is highly sensitive to the rate of learning, if this rate is very high, the algorithm can oscillate and become
unstable or is very small the algorithm will take too much to converge. Common algorithms can improve if allowed in
the process learning rate is varied.Such training system generates an error 0.0219 training for training matrix and 0.0179
for the test matrix for a multilayer neural network 2 intermediate layers of neurons 19 each.
V. CONCLUSIONS
- The more layers has the network, it is easier to stabilize the synaptic weights of the same and improve
performance.
- While the number of neurons increases, the error value decreases until value It stabilizes in (0.04), which
proves that the neural network is better trained if the number of neurons in the intermediate layer is greater.
- The performance of the neural network, not only depends on the quantity of neurons and layers, it also depend
of the type of training that we use for the net.
VI. REFERENCES