Wednesday 20 July 2011

SCHEMENAUER AND THE XOR GATE

SCHEMENAUER AND THE XOR GATE

IMPLEMENTING ANN IN PYTHON

I was searching for Artificial Neural Networks (ANN) implementation in Python. I came across the following;
  1. FANN - C library with python bindings
  2. PyBrain
  3. NeuroLab
  4. PyNN 
  5. BPNN - Not a library, solitary script by Neil Schemenauer
THE XOR PROBLEM

The XOR problem has some history in the evolution of ANN methods. The XOR function is not linearly separable and cannot be realised using only one layer of ANN.

TINKERING WITH SCHEMENAUER'S CODE

Schemenauer's code has default training values for a 2 input XOR gate.


Schemenauer recommends using of a (2,2,1) network (viz. a network with two input, two hidden, and one output nodes) and the output is very much as desired, in the limits of errors of the ANN.  

XOR Output for a (2,2,1) Back Propogation Neural Network;
([0, 0], '==', [0.025608579041218795])
([0, 1], '==', [0.98184578447794768])
([1, 0], '==', [0.98170742564066216])
([1, 1], '==', [-0.021030064439813451])
However, playing around with the number of hidden layers has interesting results,

XOR Output for a (2,1,1) Back Propagation Neural Network; 
([0, 0], '==', [0.0020536886211772179])
([0, 1], '==', [0.68437587415369783])
([1, 0], '==', [0.68413753288547252])
([1, 1], '==', [0.6856616998850974])
The output of (2,1,1) clearly confirms the XOR problem !

Increasing the number of hidden layers indiscriminately, leads to anomalous output.

As an example, XOR Output for a (2,25,1) Back Propagation Neural Network;
([0, 0], '==', [0.99999643777993841])
([0, 1], '==', [0.99999911082329096])
([1, 0], '==', [0.99999280130316026])
([1, 1], '==', [0.99999824824488848])

Anomalous behaviour comes into play from about 12 hidden nodes.


REFERENCES
(1) An introduction to neural networks

Wednesday 28 July 2010

FIREFOX EASTER EGGS

FIREFOX EASTER EGGS

In mozilla firefox type in about:robots and then see the magic unfurl !


ABRACADABRA ! .......


..... if you can handle surprises then try about:mozilla



Sunday 20 June 2010

MPLAYER !

I will keep it short and simple ! I had never come across a movie player which is controlled - NOT by a GUI, but command line in the terminal window ! ..... and then I came across MPLAYER .

I guess using Unix/Ubuntu is a 'learning' experience !

Wednesday 28 April 2010

HEART TO HEART

HEART TO HEART

A very interesting mathematical recreation is to conceive coherent drawings using algebraic functions. Bezier curves are the authentic way to generate such computer graphics. Bezier came up with his genius in early 60s while designing automobile parts. Other popular means are Hermite curves and Splines.

Though effective, these means are involved and computationally demanding. However, sometimes by providence we do have sensible shapes made out from simple functions.

PLOTTING THE HEART IN MATLAB

I discuss plotting a heart using simple cardioid, polar plots and algebraic equations

(a) The simplest one

The simplest 'heart curve' is the cardioid. It is not truly a heart, however it looks somewhat similar to one.


(b) Polar plot

A polar curve given by;

gives a near perfect heart !

The Matlab command line is;

>> ezpolar('((sin(t)*sqrt(abs(cos(t))))*(sin(t) + (7/5))^(-1)) - 2*sin(t) + 2')

(c) Algebraic Equation

A heart can be made from the implicit algebraic function,



However tinkering by adding a factor of (0.35) and (1.3) to the terms makes the heart more aesthetic.


The Matlab command is,

>> ezplot('(0.35)*((x^2 + y^2 - 1)^3) - (1.3)*(x^2)*(y^3)');

It is worth noting that for using ezplot t, x and y doesn't have to be defined.


(d) Another Algebraic Equation

This one is due to Matt ....




.
.
.
...then again forget MATLAB, we do have <3 to our rescue !



REFERENCES
(1) ezplot
(2) stackoverflow question 2720180
(3) stackoverflow question 323584
(4) Heart Curve page
(5) Wolfram page
(6) Bezier Heart in Gimp