AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Exception in BP learning

The forum is to discuss topics from different artificial intelligence areas, like neural networks, genetic algorithms, machine learning, etc.

Exception in BP learning

Postby Edrisfm » Sat Jan 09, 2010 7:39 pm

Hello
Excuse me for my bad English!
Subject of my project is prediction soccer competitions at the end of a half league with neural networks. I want use Multy Layer Perceptron(Does it work?!). In my project the network was trained with the statistics of first half of the half league such as : Corners count, Offsides count, Accurate passes count and etc. I'm using two 2D array (input[][] and output[][]) for training the network.Data are stored in a file(-La Liga Statistics-its not completed yet! but the statistics of 2 weeks are ready.).
Features for prediction are:
TeamNr,Possession,Shoot,ShootOnTarget,Corner,Offside,AccuratePass,BadPass
In addition there are 16 features for 2 teams.(16 neuron for first layer)
The content of data file is:
Code: Select all
20,
1,Barcelona
2,Valladolid
3,Espanyol
4,Valencia
5,Mallorca
6,Athletic Bilbao
7,Atletico Madrid
8,C.D Numancia
9,Malaga
10,Almeria
11,Deportivo la Curona
12,Real Madrid
13,Osasuna
14,Villarreal
15,Racing santander
16,Sevilla,,
17,Real Betis Balompie,,
18,Recreativo Huelva,,
19,Sporting de gijon,,
20,Getafe,,

TeamNr1,Possession1,Shoot1,ShootOnTarget1,Corner1,Offside1,AccuratePass1,BadPass1,Goal1,TeamNr2,Possession2,Shoot2,ShootOnTarget2,Corner2,Offside2,AccuratePass2,BadPass2,Goal2
---------------------------
1,,,
3,38,10,2,1,2,160,27,1,2,62,11,1,9,2,312,83,0
4,54,17,6,5,5,340,52,3,5,46,16,2,6,4,284,38,0
6,46,10,4,2,4,215,42,1,10,54,11,5,6,0,266,59,3
7,56,25,9,11,3,306,59,4,9,44,7,2,7,2,210,36,0
8,27,5,2,2,6,150,33,1,1,73,25,5,7,1,501,77,0
11,38,11,3,6,3,250,53,2,12,62,18,4,5,2,426,72,1
13,44,10,1,10,1,197,58,1,14,56,12,3,2,3,288,66,1
15,38,7,2,4,2,222,59,1,16,62,13,4,6,0,422,42,1
17,60,8,2,2,5,331,54,0,18,40,13,6,2,4,189,43,1
19,42,13,2,2,5,216,55,1,20,58,16,9,7,2,322,48,2

2,,,
1,74,18,7,9,7,532,72,1,15,26,2,1,1,3,130,38,1
16,66,26,13,9,1,425,61,4,19,34,13,8,3,0,181,41,3
2,33,9,4,9,1,126,36,2,7,67,19,8,5,4,324,78,1
10,41,12,3,2,0,194,37,2,4,59,11,3,3,4,306,52,2
20,56,25,6,7,0,327,53,0,17,44,16,4,6,1,250,34,0
9,48,11,2,6,2,194,63,0,6,52,11,4,4,2,226,13,0
5,48,11,3,3,1,267,48,1,13,52,14,7,4,3,308,32,1
12,63,19,10,6,6,414,78,4,8,37,12,4,3,3,210,43,3
18,53,8,3,7,0,282,76,0,3,47,4,1,4,4,239,31,1
14,57,19,7,10,2,314,63,1,11,43,6,1,3,6,236,38,0



This is my code for creating and learning the MLP network, but in running time there is an exception.
Where is my mistake???
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(), 20, 16, 2); // I think that
            // the origin of exception is the parametes that I set.
            BackPropagationLearning teacher = new BackPropagationLearning(MlpNetwork);

            // I use the below if(commented) for check the length of input vector but I understood that input.Length is
            //equal with MlpNetwork.InputsCount
            /*if (input.Length != MlpNetwork.InputsCount)
                MessageBox.Show("Not Eq");*/

            teacher.RunEpoch(input,output);


The exception said: "Wrong length of the input vector."
Image

You can download my project from below link:
http://www.fileden.com/files/2009/6/5/2467593/proj.zip

Thanks
Edrisfm
 
Posts: 5
Joined: Mon Jan 04, 2010 5:04 am
Location: Iran - Kermanshah

Re: Exception in BP learning

Postby thizzleboom » Sun Jan 10, 2010 1:44 am

I think you need to change...
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(), 20, 16, 2);


Looks like you are setting the first layer to 20 but want 16 instead.
thizzleboom
 
Posts: 8
Joined: Sat Aug 15, 2009 10:13 pm

Re: Exception in BP learning

Postby Edrisfm » Sun Jan 10, 2010 3:55 am

thizzleboom wrote:I think you need to change...
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(), 20, 16, 2);


Looks like you are setting the first layer to 20 but want 16 instead.


thanks
I changed the code:
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(),16, 2);


Now, there is no exception :P.
But
Where I set the inputs count??
the second parameter in ActivaionNetwork constructor is inputs count(in my project is 20 <every week 10 games and 2 weeks = 20>). Isn't it??? :?:

ActivationNetwork(function,inputs count, neurons count in layer 1,neurons count in layer 2,...,neurons count in layer N);
Isn't this true??
Edrisfm
 
Posts: 5
Joined: Mon Jan 04, 2010 5:04 am
Location: Iran - Kermanshah

Re: Exception in BP learning

Postby andrew.kirillov » Sun Jan 10, 2010 11:53 am

Hello,

Take a look at documentation - it tell quite clearly how to specify network's input size and number/size of layers.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3436
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: Exception in BP learning

Postby thizzleboom » Sun Jan 10, 2010 11:10 pm

Edrisfm wrote:
thizzleboom wrote:I think you need to change...
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(), 20, 16, 2);


Looks like you are setting the first layer to 20 but want 16 instead.


thanks
I changed the code:
Code: Select all
ActivationNetwork MlpNetwork = new ActivationNetwork(new SigmoidFunction(),16, 2);


Now, there is no exception :P.
But
Where I set the inputs count??
the second parameter in ActivaionNetwork constructor is inputs count(in my project is 20 <every week 10 games and 2 weeks = 20>). Isn't it??? :?:

ActivationNetwork(function,inputs count, neurons count in layer 1,neurons count in layer 2,...,neurons count in layer N);
Isn't this true??

I think you might need to rethink your network input. You should not give the team id to the network as input.
thizzleboom
 
Posts: 8
Joined: Sat Aug 15, 2009 10:13 pm

Re: Exception in BP learning

Postby thizzleboom » Sun Jan 10, 2010 11:12 pm

Here's a good example of how to structure your input... http://www.uk-neural.net/football.html
thizzleboom
 
Posts: 8
Joined: Sat Aug 15, 2009 10:13 pm

Re: Exception in BP learning

Postby Edrisfm » Sun Jan 24, 2010 7:12 pm

thizzleboom wrote:Here's a good example of how to structure your input... http://www.uk-neural.net/football.html

Thanks, I'll read it.
Edrisfm
 
Posts: 5
Joined: Mon Jan 04, 2010 5:04 am
Location: Iran - Kermanshah

Re: Exception in BP learning

Postby Edrisfm » Sun Jan 24, 2010 7:22 pm

thizzleboom wrote:I think you might need to rethink your network input. You should not give the team id to the network as input.


I think that TeamNr can be useful. Assume that Barcelona has TeamNr=5. Now, Barcelona maybe not good in a game, but we know that Barcelona even can win with the bad statistics. Here TeamNr can cover this. Except this, TeamNr can be a uncertain factor(every feature that are forgotten). Its my idea and I don't know that it is true or false completely!
Edrisfm
 
Posts: 5
Joined: Mon Jan 04, 2010 5:04 am
Location: Iran - Kermanshah




Return to Artificial Intelligence