Friday, 30 November 2007

C# XOR Neural Network

Please do not use the code in this blog for academic work

Over the last couple of days I've been locked away in my room programmin a neural network. I know not the most fun thing I can be doing.

The XOR Neural Network users back propergation to calculte the errors of each individual connection in the network. This is done by finding th error at the output to the network and then passing this back to the networks previous nodes.

My current alpha version of the network will train the network on a set of test data and then can be used on a live set of data to see if it works, at the current time I only have the network working for unipolar input as the bipolar input is sticking when the output hits zero. This causes the messy problem of multiplying by zero when we pass back the error. I still have yet to figure out how to solve this, but will keep you informed when I find out.

The code below is part of my network:

private void train(object sender, EventArgs e)
//set training set
// input 1 input 2 desired out
td[0, 0] = 0; td[0, 1] = 0; td[0, 2] = 0;
td[1, 0] = 0; td[1, 1] = 1; td[1, 2] = 1;
td[2, 0] = 1; td[2, 1] = 0; td[2, 2] = 1;
td[3, 0] = 1; td[3, 1] = 1; td[3, 2] = 0;

//randomise weights

//do while loop checking to see if training is complete
E = 0;
for (vector = 0; vector < 4; vector++)

forwardsprop(2, 2);

double output = calculate((y1[0] * w2[0]) + (y1[1] * w2[1]));

double error = calcerror(output);


chageweight(error, 2, 2);

E += cycleerror(output);

}while(E>Emax && number < epoch);

MessageBox.Show("Training Complete, E = " + E.ToString() + " Epochs = " + number.ToString());

This is the general overview of what happens in the program, the training section of code will repeatedly input the training data and calculate the new weights for each of the connections this is done by first forward propogation to get the output of the network.

//propogate forwards throught the network
public void forwardsprop(int inputs,int outputs)
int i = vector;
int count = 0;
for(int y=0; y<outputs; y++)
y1[y] = 0;

for(int j=0; j<inputs; j++)
y1[y] += td[i, j] * w1[count, j];

y1[y] = calculate(y1[y]);


This gives the output for each node and also the overall output of the network. Given this overall out put we can then find the error in the system, using the desired output in the training set and pass this value back through the network. This is called back propogation.

//pass errors back through the network to calculate new weights
public void backprop(double error)
for (int i = 0; i < 2; i++)
double nodeerror = (error * w2[i]);

nodeerror = (y1[i] * (1 - y1[i])) * nodeerror;

chageweight(nodeerror, i, 1);

Once we have all the errors for every node in the network we can work out have we need to change the weightings of each of the connections to reduce the ammount of error in the netwok.

//messy way to calculate the new weights for a connection
public void chageweight(double error, int node, int layer)
int i = vector;

if (layer == 1)
for (int j = 0; j < 2; j++)
double wadjust = n * error * td[i, j];
w1[node, j] += wadjust;

if (layer == 2)
for (int j = 0; j < 2; j++)
double wadjust = n * error * y1[j];
w2[j] += wadjust;

The weights havenow been changed in the network and next time you put data into the network the ammount of error given will be less.

To train the network you continually do this process untill you have reach Emax the maximum ammount of error that the system is allowed, or untill you have reached the desired number of epochs (amount of loops of all the data in the training set).

Once the system has been trained you can then test out the system to see if it actually works for the desired purpose.

As can be seen in the images work still needs to be done to the network, however the hard stuff is done and I can eventually get on with the other sections of work within my project. Along with trying to get the code to work for bipolar networks.

Thursday, 29 November 2007

Silverlight V2.0

Silverlight V1.0 has been going for a short time now, with V1.1 adding parts of the .NET framework still in Alpha. However there is already news of Silverlight V2.0.

Version 2.o will add more of the .NET framework to Silverlight including a set of rich controls such as textboxes, buttons and. lists, all the common controls you will need for a basic Silverlight app. This really exitetes me as it will make it much easier for people to develop with Silverlight and will be less of a faf than it is currently. There are also alot more content of the V2.0 release that MS are not willing to make public at the moment, but be sure that come release date, Silverlight V2.0 will deffinatly be crowned a Flash killer.

For the full article check out Scotts full blog post here.

Friday, 23 November 2007


MIX @ MMU is going to be my first major event as an MSP and hope as many people from the universiy can make it down. It promises to be a great event with talks from myself and Phil Winstanley. Not to mention the free beer and pizza (if we dont get kicked out by the Dean lol).

Tuesday, 20 November 2007

Visual Studio 2008

Visual Studio 2008 is now avaliable to all those with an MSDN subscription!!

Friday, 16 November 2007

Microsoft Manchester

Just recived some inside information that Microsoft are going to be building a new office in Salford Quays. Along with Microsoft, Google will be building a Manchester office and both are currently trying to out do each other with the design of their buildings.

Hopefully this will mean more jobs avaliable for students such as myself :)

Saturday, 10 November 2007

Visual Studio 2008 November Release

It was announced at Tech Ed Barcelona this week that Visual Studio 2008 (Codename Orcas) will deffinatly be released by the end of the month!!

For more informaton click here.

Friday, 9 November 2007

The NEW waterfall model

Whilst browsing for information for my final year project I found this great diagram of how the waterfall model should truly be implmented.

Lets see all you code gurus get out there and implement this method!

Silverlight Physics

Take a look at these amazing silverlight demos that I found via Mike Ormonds blog:

These silverlight apps are using the farseer physics engine, which can be freely downloaded to create brillinant web games which include physics.

More about the Farseer Engine:

The Farseer Physics Engine is an easy to use 2D physics engine designed
for Microsoft’s XNA and Silverlight platforms. The Farseer Physics Engine
focuses on simplicity, useful features, and enabling the creation of fun,
dynamic games.

Thursday, 8 November 2007

Register for the Imagine Cup and win an Xbox 360

Want the chance to win an Xbox 360? Well every month Microsoft will be giving one away, all you have to do is register your interest in the Imagine Cup. Go to:

Then click on register, easy as that!

The Imagine Cup is the world’s largest technology competition with students all over the world taking part. It gives you brilliant opportunities to build up connections with people in a wide range of computing companies, last year one of the UK’s entrants was offered a job based upon his entry into the imagine cup.

This year the Imagine Cup is being held in Paris, France and with a little effort you will be able to get an all expenses paid trip there to compete all you have to do is enter. Also for the first time ever the UK will be giving out country specific prizes, to some of the groups that reach the third round of the competition. Some of these prizes include 2week work placement with the Microsoft Popfly team in Seattle, 2 week work placement with a Microsoft Games Studio, HD Video Camera and loads of Xbox 360 Elites.

For more information on the Imagine Cup check out the website:

Unreal Tournament 3 BETA

The Beta Demo for UT3 has been released! It is extremly good and theres more gun toating action than you can shake a stick at!

Download it now from here:

Also check out the UT3 site:

Wednesday, 7 November 2007

Building Dynamic Web Applications with Microsoft Silverlight

Want to learn about the latest internet technologies? Well now’s your chance, Mike Ormond a Microsoft Development Evangelist is coming to Manchester on the 15th November to give a presentation on developing web apps using Microsoft’s latest web technology Silverlight.

Silverlight is a cross-browser, cross-platform plug-in for delivering rich media experiences and applications for the Web. Silverlight provides a highly productive platform for designers and developers to collaborate in building a new generation of web experiences enabling you to build visually stunning interactive content and applications that run on multiple browsers and operating systems.

Mike will also be taking a look at XMAL a mark-up based language based on XML, which is currently being used to develop rich media experiences such as those you will see when developing with Silverlight or WPF.

For more information on the free event go to:

or check out Mike Ormond’s blog at:

Hope to see you all there!

Monday, 5 November 2007

Great Presentation Tools

Zoomit and NLarge are two great tools that can be utalized when doing presentations, each allow you to draw onto the screen to highlight various points of intrest to your guests.

This makes a presentation even more interactive and makes the crowd really feel part of the action. Both have functions allowing you to zoom into the screen, which is especially useful when giving a code demo and you want to get across the importance of a section of code.

Guy Smith Ferrier (Microsoft MVP)discusses both of these peices of software in his blog post NLarge Vs Zoomit, with the opinion that Zoomit is the better of the two products.

Give the software a download and make up your own mind. I for one really like the extras that the software adds to a presentation.

Friday, 2 November 2007

IBM Mainframe Contest

So we have all heard of Microsoft's Imagine Cup, it now looks like IBM want in on the student tech contests with their Mainframe Contest.

This is split into 3 rounds the first of which helps to get the students thinking about mainframes and a general introduction, with the first 200 students to finish the stage winnig IBM mainframe t-shirts.

Stage 2 is a much more practical stage withe students using the skills they learned in stage 1 to do various programing tasks. Again the first 25 students to complete the stage get Sony PSPs

The final stage the most challenging stage with students working on a project over a number of weeks, with the best 3 entries winning think pads.

Also up for grabs is a trip to IBM Hursley where the lucky student will be able to see what life at IBM is really like.

Check out the website at for more information.

Microsoft Graduate Scheme!

I just got some really good news, I have passed the first round of applications for the Microsoft Graduate Scheme, the first round was submitting my details online and answering a number of general work questions such as giving details of when I have worked as part of a team etc.

Now all I have to do is wait for a phone interview, where I will talk with someone at the recruitment agency. Hopefully this will not be too bad as I can talk for hours on why I want to work for MS and what relevant work I have done.

Ill keep you posted!