<< January, 2008 >>
SMTWTFS
12345
6789101112
13141516171819
20212223242526
2728293031
Search Blog

Categories
Archives
RSS

Powered by
BlogCFM v1.14

25 January 2008
An attempt at neural network programming in Actionscript 3
After studying for a couple of tests for school, i had some free time on my hands and i decided to take a shot at implementing a perceptron in actionscript. Wikipedia quotes "The perceptron is a type of artificial neural network invented in 1957 at the Cornell Aeronautical Laboratory by Frank Rosenblatt. It can be seen as the simplest kind of feedforward neural network: a linear classifier."

EDIT: I will be posting more about what this code is, and making the code better, right now its 1 am in the morning and I have an exam tommro !.

Normally this type of stuff is implemented on languages such as Java and C, but i decided to give it a shot in Actionscript, below is the code for a fully working Perceptron, however it is really CPU intensive, it did not work on my 3 year old pc, but it did work on my laptop which is fairly new but even then it took a while. I will optimize the code, but tomorrow after my exam, the code is below for you to learn from. enjoy.
  1. package {
  2.     import flash.display.Sprite;
  3.     public class Perceptron extends Sprite
  4.     {
  5.         public var impressionPattern:Array;
  6.         public var goalPattern:Array;
  7.         public var inputNeurons:int;
  8.         public var outputNeurons:int;
  9.         public var numPattern:int;
  10.         public var weightFactor:Array;
  11.         public function Perceptron()
  12.         {
  13.             // Impression pattern
  14.             this.impressionPattern = new Array(
  15.                                                 [0,0,0,0],
  16.                                                 [0,0,0,1],
  17.                                                 [0,0,1,0],
  18.                                                 [0,0,1,1],
  19.                                                 [0,1,0,0],
  20.                                                 [0,1,0,1],
  21.                                                 [0,1,1,0],
  22.                                                 [0,1,1,1],
  23.                                                 [1,0,0,0],
  24.                                                 [1,0,0,1]
  25.                                                 );
  26.             // Goal Pattern
  27.             this.goalPattern = new Array(
  28.                                          [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  29.                                          [1, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  30.                                          [1, 1, 0, 0, 0, 0, 0, 0, 0, 0 ],
  31.                                          [1, 1, 1, 0, 0, 0, 0, 0, 0, 0 ],
  32.                                          [1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ],
  33.                                          [1, 1, 1, 1, 1, 0, 0, 0, 0, 0 ],
  34.                                          [1, 1, 1, 1, 1, 1, 0, 0, 0, 0 ],
  35.                                          [1, 1, 1, 1, 1, 1, 1, 0, 0, 0 ],
  36.                                          [1, 1, 1, 1, 1, 1, 1, 1, 0, 0 ],
  37.                                          [1, 1, 1, 1, 1, 1, 1, 1, 1, 0 ]
  38.                                          );
  39.                                          
  40.             this.inputNeurons = this.impressionPattern[0].length;
  41.             this.outputNeurons = this.goalPattern[0].length;
  42.             this.numPattern = this.impressionPattern.length;
  43.             this.weightFactor = new Array();
  44.             var i:int;
  45.             var k:int;
  46.             for(i = 0; i < 20 ; i++){
  47.                 weightFactor[i] = [0,0];
  48.                
  49.             }
  50. this.wthdoesthisdo();
  51.            
  52.            
  53.             }
  54.            
  55.             public function delta():void{
  56.                 var autoCorrect:Boolean = false;
  57.                 var error:Boolean = false;
  58.                 var learningFactor:int = 0.2;
  59.                 while(!autoCorrect){
  60.                     error = false;
  61.                     var i:int;
  62.                     for(i = 0; i < this.numPattern; i++){
  63.                         var output:Array = setOutputVal(i);
  64.                             var j:int;
  65.                             for(j = 0 ; j < this.outputNeurons ; j++){
  66.                                 if(this.goalPattern[i][j] != output[j]){
  67.                                     var k:int;
  68.                                     for(k =0;k <this.inputNeurons;k++){
  69.                                         this.weightFactor[k][j] = this.weightFactor[k][j] + learningFactor * this.impressionPattern[i][k] * (this.goalPattern[j][j] - output[j]);
  70.                                     }
  71.                                 }
  72.                                 var z:int;
  73.                                 for(z=0;z<output.length;z++){
  74.                                     if(output[z] != this.impressionPattern[i][z]){
  75.                                         error = true;
  76.                                     }
  77.                                 }
  78.                             }
  79.                     }
  80.                     if(!error){
  81.                         autoCorrect = true;
  82.                     }
  83.                    
  84.                 }
  85.             }
  86.            
  87.    
  88.             public function setOutputVal(patternNo:int):Array{
  89.                 var bias:int = 0.7;
  90.                 var result:Array = new Array([this.outputNeurons]);
  91.                 var toImpress:Array = new Array()
  92.                 toImpress =  this.impressionPattern[patternNo];
  93.                 var i:int;
  94.                 var j:int;
  95.                 for(i =0 ; i < toImpress.length ; i++){
  96.                     for (j=0;j < result.length;j++){
  97.                         var net:int =  this.weightFactor[0][j] * toImpress[0] + this.weightFactor[1][j] * toImpress[1] + this.weightFactor[2][j] * toImpress[2] + this.weightFactor[3][j] + toImpress[3];
  98.                         if(net > bias){
  99.                             result[j] = 1;
  100.                         }else{
  101.                             result[j] = 0;
  102.                         }
  103.                     }
  104.                 }
  105.                 return result;
  106.             }
  107.             public function printMatrix(matrix:Array):void{
  108.                 var i:int;
  109.                 var j:int;
  110.                 for(i = 0; i < matrix.length; i++){
  111.                     for(j=0;j<matrix[i].length;j++){
  112.                         trace(matrix[i][j]);
  113.                        
  114.                    
  115.                     }
  116.                 }
  117.             }
  118.            
  119.             public function wthdoesthisdo():void{
  120.                 trace("before learn");
  121.                 this.printMatrix(this.weightFactor);
  122.                
  123.                 this.delta();
  124.                 trace("after learn");
  125.                
  126.                
  127.                 this.printMatrix(this.weightFactor);
  128.                
  129.             }
  130.            
  131.            
  132.     }
  133. }
Posted by Faisal at 12:21 AM | Link | 2 comments
22 January 2008
Your Favorite API - Tell us now
With the release of the open source social network in a few weeks, I'm calling the community to present us with your favorite API. Facebook, MySpace , Flickr, anything and we will include most if not all in the social network as part of the release so you wont have to dig through the source to modify it, it will already be there
Posted by Faisal at 9:48 PM | Link | 0 comments
21 January 2008
G-uniX Open Source Initiative { Coldfusion and Flex never had it this good }
Over the next few months G-uniX is launching 4 open source flex and Coldfusion projects. Details about the other 3 will be revealed later however the first will be an open source Social Network developed in Flex 3 and Coldfusion 8 . I'm currently looking into the best open source license and how to market it, however rest assured for the adobe flex and Coldfusion community the source code will be released with the social network going live on the servers .

All the details on the social network are tight lipped for now, but if you have been reading my blog posts on the future of web applications, you might have a hint on what to expect
Posted by Faisal at 5:20 PM | Link | 0 comments
20 January 2008
Ribbit Platform
Part 2
Recently i wrote a pseudo rant on how the ribbit website sign-up sucks. Someone commented to email one of the lead guys at ribbit and within 5 hours they emailed back with all the accounts i made and all the passwords for those accounts all. Great work , i needed this component as im developing an application for my school that will help in marks management and classroom collaboration and ribbit is a must
Posted by Faisal at 12:26 PM | Link | 0 comments
Dont Put Your Eggs In One Basket
Silverlight and The Flash Platform
A long time ago , one of my teachers told me not to put all your eggs in one basket. I looked at him and gave a puzzled look and said "im not a farmer". Now obviously I know what this means, and ive learned to apply this "formula" to daily life and most importantly programming. Recently after the announcement on our home page that says G-uniX Supports silverlight development, ive gotten a few requests from clients to build silverlight applications. I.M.O Silverlight still has a long way to go before it can compete directly head on mono-e-mono with the flash platform, but nonetheless it is still a cool tool to produce rich web applications on . As a developer , i advise other developers not to soley ride on the adobe bandwagon, Im not an adobe hater, i love adobe ,flex , flash and i dream to some day work at adobe but by broadening your skills you open yourself to more challenges and in turn more income.
Posted by Faisal at 12:17 PM | Link | 0 comments
Cloverfield
Worth The Wait..
Just got home from seeing the movie, pretty cool if you ask me. A couple of my buddies got motion sickness because of the Blair with project shaky cam effect, but to me it seemed a unique way of getting the audience to relate to the movie and become part of the events. Its 5/5 for me, great movie .
Posted by Faisal at 1:23 AM | Link | 2 comments
18 January 2008
Next generation of web applications
A.I
I have been doing a lot of neural network and artificial intelligence reading over the past few months , and the thing that comes most to mind when i think about these fields is how they can be applied to modern web applications. What Artificial intelligence is in a nutshell simplified kindergarten manner is teaching the computer , human logic. By Human logic i don't mean if and else statements, but i mean more like analyzing the data and finding out what is what . A good example is that in math when were doing equations , some people tend to put x = 3 , or some people put 3 = x , depending on there preference. However if you define in programming , if you put x = y , and y = x  they are 2 different things. Why cant the computer know what we are trying to imply.

why cant we make our flex applications, coldfusion applications , c , c++ , java application's more smarter by adding these analyzing capabilities. Of course there are AI in games and some high level software, but AI isn't only meant for that. For example, flickr can benefit with A.I by writing intelligence into there system that combines recognition algorithms and sorts out the pictures by who or what is in them and not only the tags. Think of how much power this would give Flickr. If i wanted to search for a blue chair, it would find all the pictures of a blue chair and display them, or if i wanted to find a man wearing a blue shirt, it would find a man wearing a blue shirt. As computers get more and more powerful, i don't think that these types of home level A.I or HLAI (eh lay) are far away.
Posted by Faisal at 6:30 PM | Link | 1 comment
17 January 2008
Ribbit Website Nonsense
So 2 weeks  , i signed up to download the api for ribbit beta 1 , they said sign up and in 3 business days theyll send you an email back. Thats cool, but its been 2 weeks, so during that time i signed up with 2 other accounts and same thing, no email back. I contacted there support and nothing from there either, I could have used Ribbit for a flex application in developing for the school system here in canada but what use is it when i cant even get an email from them.
Posted by Faisal at 10:56 PM | Link | 1 comment
15 January 2008
Give me Desgin View For Linux and Ill Ditch Windows for life
I Promise, the second adobe releases design view for flex builder in Linux, that will be the second i install Linux on my system as the host .
Posted by Faisal at 8:22 PM | Link | 2 comments
14 January 2008
How HD DVD can win back the market share
Use the Force..
Recently I have been reading all about the so call "death" of HDDVD. I'm a great HD DVD supporter, i mean i have the matrix collection on it, and 300 and i love the quality and the bonus features of 300. I really don't want to go buy a Blu Ray dvd player right now, or in the near future. But i do think that HD DVD still has a chance, all it has to do is convince Lucas arts into releasing The complete star wars trilogy on HD Dvd Only and voila!. What are your thoughts ?
Posted by Faisal at 4:38 PM | Link | 1 comment
04 January 2008
Asql , What it means for developers
I really think ASql is the most underrated , unnoticed actionscript library ever. Asql basically eliminates the middle tier in "most" web applications. The middle tier can be Coldfusion, Dot Net , or anything that is being used to communicate to your database to fetch query's and get results. This means two things, 1) If you are developing a small database interactive application and you don't know PHP,and you don't want to pay for Coldfusion hosting on your web host then ASQL is a godsend. Another thing (I am not sure about this) is that this will effectively speed up your query's, because instead of flex having to communicate to coldfusion, coldfusion cfcs processing the request to the database and then the database returning the results to the method called by Coldfusion, then the method doing what it is suppose to do, and finally returning what the user wanted back to flex, instead of this process , using ASQL Flex only has to communicate to the database and the database returns the data, after the AVM2 is so fast that it can do the processing of the query in a jiffy.

What I want to do with ASQL is help the developer (Mooska)  out and make it much better, I have started modifying the code (ASQL IS OPEN SOURCE!), however i really want to get involved in this project. If the developer of ASQL is reading this then comment and well get in touch (If you want).

Links

http://asql.mooska.pl/
Posted by Faisal at 5:35 PM | Link | 7 comments
Offical Word From Ebay
Yesterday night i posted an entry on how the contest rules seem to be confusing over the ebay widget contest. But quick response from ebay have cleared up that confusion. Read the entry and comments in the previous post to get all the details. Thank you sunny from ebay.
Posted by Faisal at 12:48 PM | Link | 0 comments
03 January 2008
Ebay Widget Contest Rules Confusion ?
I was reading the contest rules , and i came across something that seems really confusing. At first they are saying to use their ebay api, but in the next point they say cannot use cached ebay data including shopping api .

WIDGET REQUIREMENTS:
  • Widget must be built using Adobe Flash or Flex;

  • Widget must include eBay Data (as defined below) acquired through eBay Shopping API (using eBay Trading API is not allowed);

  • Widget may not use cached eBay Data, (meaning any data returned by the eBay Shopping API, including, but not limited to, bid price, gallery image, Buy-It-Now price, listing end time, eBay Seller ID, and item description);

Can anyone clarify this for me?
Posted by Faisal at 5:59 PM | Link | 7 comments