Monday, 9 January 2017

New Project ANt Clusterer - "Droping off or Picking up?"

My latest project is an ANt clusterer that will gather together data with similar properties within a certain range.

It will work by Random ANts running about a Grid picking up Data and carrying it with them until they find a suitable location to drop off.

At the present stage ANt 0.1 it has managed to pickup every peice of Data and has left behind plenty of nice ANt poo's!😊


Fig 1. ANt Poo's

Yeah its not ready yet. It is supposed to move the Food around not eat it all and leave ANt poo's everywhere.


 "Dropping off or picking up?", GhostBusters(1984).

ANt finally got there and clustered the patterned data into bands. Each pattern is simply a binary 2d array with random bits they are represented on the Grid with their summed totals.

To begin with I simply used their Summed integer value for the ANt to perform its two functions Drop off or Pickup.

It initially didnt score well and this was because I was evaluating each ANt's probability against a Random value. Without the Randomised Roll of the Dice it evaluates the Probability of either Dropping Off and Picking Up against a single value.

So technically speaking its not a probability. Anyway it has proven to be deterministic after 50,000 iterations with 15 ANt's it produces Bands of each pattern.

It uses the Binary representation of each pattern instead of its Summed Integer value and compares the Carried Pattern or the Pattern found at its present location to create a Density of Similar Patterns within a fixed Radius of its location. I got the low down from here.

The Density function is simply :

Sum{|PatternX[n]-PatternY(r)[n]|} / NumPatterns

NumPatterns is the Number of Patterns within the Radius of the ANt
PatternX is the Pattern either carried by the ANt for Dropping Off or
the pattern found at the ANt's location for Picking Up

The ANt needs to Pick up a pattern if the Density of simularity around it is low. It needs to drop a Pattern if it finds the Density surrounding its location to be high.

Density is normalised using Exp(-Const*Density) to create a Probability of an action of:

1-Exp(-Const*Density) / 1+Exp(-Const*Density) for Drop Off

and
                                        1 -
1-Exp(-Const*Density) / 1+Exp(-Const*Density) for Pickup

With these Bands I can now classify each pattern as belonging to a Membership denoted by the Band in which it has been placed.

However I was expecting it to create square Clusters for each Pattern. The ANt seems to have a lilt towards Bands. It also seems to have placed the Bands in order of the its Summed value with the highest at the top.

....I don't know why.

I now need to see how I can acheive this Banding faster with fewer ANt's and for more complex patterns. It would be beneficial also if each ANt could learn to put patterns into Bands that are numerically disimlar. As the ANt is improved with learning to classify more complex patterns there will be scope for speciation or casting amongst the ANt's as some ANt's must learn to classify and therefore recognise specific types of Data.

The end result being an Algo which is domain specific and can classify patterns of different types to Groups within Groups.




Fig. 1 Initial Success - ANt Bands (The little hat shows where it has picked up from, the star shows where it has dropped off)


The ANt story continues have now just applied the ANt to an image to see if it can distinguish primitive features and produce the same Bands now for more complex Data. The results look good with little tinkering this helpful buddy partitioned a complex image into three distinct Bands. At this stage the ANt should have performed a rudimentary Histogram on the Image. I have yet to see however because allthough I have a Binary output similar to that above I have not written the function yet that converts the Grid data produced by the ANt back into jpeg format. Stay tuned to see the output...😋

ReadMe


So far so what. I have plugged the JPEG reader into the ANt program with
limited success due mainly to the fact that I have yet to unscramble the image properly. Also not all the ANts have been instructed to drop their loads and thus we are missing data on the Grid for reassembly into the image.

Even with all the data on the grid the image becomes distorted for every iteration. This shouldnt happen we should beable to get a perfect image out
the other end no matter how many iterations we perform as the ANts are merely labelling each block as belonging to a feature set.

Here are some images with no iterations to give you an idea about how things will proceed. Eventually these colour blocks will be pixels as each pixel will become a data element carrying with it its neighbourhood values and being clustered by the ANts accordingly.

To begin with though it is simpler to use blocks and then apply these blocks as neighbourhoods for each pixel. When this happens the grid will be much larger and thus the processing time will increase. But now that I have brought a new machine I hope to reduce this time with parallelization.

Here are the images. Any more iterations and I lose Data and the image gets distorted.



The goal will be image segmentation using a colour index taken from the Grid.

As you can see there is no segmentation as I have merely reproduced the image from the Grid data with coloured labelling applied. The Ants have yet to perform their task of clustering the image.


 Before (First Image) Random Initial state. After (Second Image) ANts have
clustered regions belonging to the Leopard.








10,000 Iterations with different Mapping functions.

It delineates features from both the Antelope and the Leopard.

Captures different features of the Lotus relating to orientation and edge
detection. Powerful ANts!

Next - will this be a suitable replacement for pooling on the CNN?

Note also it leaves the background in tact in both the two previous images.




No comments:

Post a Comment